0

Hi all.

I have a web application which upon page load, creates a number of buttons on the page. For each button which is created, i add a handler for the click event. Inside the click event code for the button, i identify the ID of the sender. I then store the button ID inside the session state. I then want to postback to a different web form, which i do by setting the autopostbackURL to "another_web_form.aspx".

My problem is that if I set the button properties to autopostback = true, the button click event will not occur because the code will move to "another_web_form.aspx".

I really need the ID of the button which i clicked to be accessable by the page of which i am posting back to (another_web_form.aspx).

This is the code on my first page:

btnEdit.ID = "btnEdit" & <a unique integer value>
            AddHandler btnEdit.Click, AddressOf btnEditSite_click
            cell6.Controls.Add(btnEdit)

This is the code on the page which i want to post back to:

'This is retrieving the value held in the session state
        Dim siteToEdit As String = Session("editID").ToString()

If the button's click event is never fired, the button ID is not assigned to the session state.

Any help would be great, thanks.

2
Contributors
3
Replies
6
Views
7 Years
Discussion Span
Last Post by judge6
1

Do not use PostBackUrl property. Use Server.Transfer or Response.Redirect method to transfer a user on another page.

0

Do not use PostBackUrl property. Use Server.Transfer or Response.Redirect method to transfer a user on another page.

Thankyou for the advice, i will look into this today.

0

Do not use PostBackUrl property. Use Server.Transfer or Response.Redirect method to transfer a user on another page.

Thanks this was exactly what i needed! I used the Response.Redirect method to pass variables to the receiving page.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.