Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Reload calling page in ASP.NET 2.0


Hi

I have a list on LinkButton controls on a page. When the link is clicked the
LinkButton.Command event does a Server.Transfer to a page which writes
binary to the HTTP output stream, e.g. a word document, pdf etc.

Response.BinaryWrite(buffer);
Response.End();

I would like to reload the page with the LinkButtons after this event to
reflect changes which are made after the download of the file.

I understand that some client script may be needed but I'm not sure how to
implement this or if something can be added to the LinkButton.OnClientClick
property.

I'm guessing that maybe I need to do a  postback and then write some client
script to open the download page? What's the neatest solution please?

Many thanks
Andrew

Hi Andrew,

When the LinkButton is clicked, in its Command event, you don't use
Server.Transfer; instead, you use ClientScript.RegisterStartupScript to
register a script to open the download page in a new window:

    void Link1_Command(object sender, CommandEventArgs e)
    {
        ClientScript.RegisterStartupScript(GetType(), "download",
"window.open('Download.aspx', '_blank')", true);
    }

#open Method (window)
http://msdn2.microsoft.com/en-us/library/ms536651.aspx

Hope this helps.

Regards,
Walter Wang (waw@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

-----------------------------------------------Reply-----------------------------------------------

I think your idea will be the easiest: on click of the link button on the
server side, do all the necessary updates and spit out JavaScript code to
open the binary streaming page. This will let the download start in another
page but at the same time refresh the current page.

Hi

Thanks for the advise. I need to include some querystring parameters. The
window.open method doesn't seem to support a querystring, e.g.

onclick="window.open('Download.aspx?ID=1234');"

I guess i need a javascript function? How would I add the function to the
aspx page?

Thanks
Andrew

-----------------------------------------------Reply-----------------------------------------------

Hi Andrew,

The window.open function can open a URL with querystring; your code looks
fine, I'm not sure what's the issue you're having?

To add a javascript function in the page, you can use
ClientScript.RegisterClientScriptBlock or
ClientScript.RegisterClientScriptBlock.

Regards,
Walter Wang (waw@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

-----------------------------------------------Reply-----------------------------------------------

Hi Walter

There's a problem with the VS web server and IE7. It works ok in Firefox
using the local server. I get this message in IE when clicking the link with
the querystring.

"Internet Explorer cannot download Download.aspx from localhost. Internet
Explorer was not able to open this internet site. The requested site is
either unavailable or cannot be found. Please try again later."

I've tested it using an IIS web server and it works ok. The only problem for
me is that it opens a blank window as well as a file download pop up window.
Do you know if I can stop the new window displaying?

Thanks again
Andrew

"Walter Wang [MSFT]" <waw@online.microsoft.com> wrote in message
news:d9vbJWKqHHA.3892@TK2MSFTNGHUB02.phx.gbl...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc