do fresh reload of page during a postback event...

G_Waddell 0 Tallied Votes 641 Views Share

Hi
I thought I'd share this with you all as it is really quite simple but I spent ages looking for it.

I have an ASP.Net App with a master page containing a tree view that holds a heirarchy of data (as opposed to site naviagation)

What I wanted was when the user clicked on the Tree the postback event for the tree would fire and I could process what node they had clicked (data level, node values, etc.) which I then store in a session variable and then I wanted to reload the current page with this new data as the page was also holding other data specific to the current node in other variables.

i.e. when not post back, the page wipes these variables and populates with whatever is needed for the new node. During post back event from other controls, I want to keep this data and only react to the postback.

So on my

TreeView_SelectedNodeChange

event I processed the node data then finished off with

Response.Redirect(Request.RawUrl)

to reload the page.

However, I was getting errors because although I had changed and wiped the data the actual page was still treating it as a post back and now had orphaned data.

It turns out I was only half way there! All I needed to do was add a flag to my

Response.Redirect(Request.RawUrl)

call which tells the server to stop executing the current page:

Response.Redirect(Request.RawUrl, true)
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.