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.

Recommended Answers

All 3 Replies

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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.