Download file Stuck in SharePoint Visual WebPart

I tried to click on a link control inside a SharePoint Visual WebPart to download the attached file where the save dialog is showing properly.But when I clicked on Save or Open button, I noticed that The page has become a hanging !



1-In front code of User Control add the following JavaScript code.

function myFunction()
{window.WebForm_OnSubmit = function() {return true;};}

2-Add OnclientClick event to the link control and assign the previous defined function.

OnClientClick = "myFunction()"

3-You can also put it in Back-End code as the following.

protected void Page_Load(object sender, EventArgs e)
{ Link1.OnClientClick = "myFunction()"; // or any other event }

Enjoy 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s