We help IT Professionals succeed at work.

PostbackURL in linkbutton

Camillia
Camillia used Ask the Experts™
on
I have a linkbutton with an onClick event;

<asp:LinkButton ID="lbFileUpload"    OnClick="FileUpload_Click" Text="File Upload" runat="server"  ></asp:LinkButton>

Open in new window


In the onClick event, I have a postbackURL. I put a debug step and it goes thru the step below but it stays on the same page:

 
protected void FileUpload_Click(object sender, EventArgs e)
    {
        lbFileUpload.PostBackUrl = "~/Main/FileUpload/DefaultFile.aspx?pageTitleId=39&patientId=" + PatientId;
    }

Open in new window


Now, If i have the PostbackURL in the aspx page, it works. I dont want it in the aspx page because I dont know how to add that "patientId"  <%# Eval("PatientPhone")%>  to the end of postbackURL.

Howcome it stays on the same page even tho it goes thru the onClick event?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Engineer
Top Expert 2011
Commented:
Because you are just updating the PostBackUrl  attribute value for the upload control and at this point the postback event has already occurred back to the same page.

You could either try updating he PostBackUrl value in the page_load event if you know the value of the patient id at this point or maybe just do a response.redirect in the click event.