Retrigger Postback

  • Thread starter Thread starter Victor Garcia Aprea [MVP]
  • Start date Start date
V

Victor Garcia Aprea [MVP]

There is no sense in triggering postback twice. Could you specify more
details of what you're after?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Read my weblog:
Followers of the IHttpHandler
http://clariusconsulting.net/vga
 
Chris,



if you'd tell a little more about your problem it would be easier to find a
solution regarding your problem. What you could do for example is to trigger
a webservice which could perform sth. for you in the background. But all
ideas, recommendations are most probably useless if your problem is this
vague.



Greetings
 
I agree to Victor. Triggering postback twice is definitely no solution!

---------------------------------------
Daniel Walzenbach
MCP

www.walzenbach.net
 
I want to click a button and have it does something before the page reloads.
I now realize the page processes the server side event after page loads. Is
there any way of triggering the postback twice. I know its a hack.....
 
I want to press a button and have it change an XML file. Those changes need
to be place before the page loads again, specifically at the page
initialisation stage. I am using the XML file to determine which controls to
add to the page. It's really long winded to explain why I need this but
this is the order I need things executed:

Load Page with button.
Press button, amend XML file.
Postback and use changed XML file in the load event.

My understanding is the postback processing takes place AFTER the load which
is too late.

If I repost the XML will have changed and the user won't notice. Currently I
have to press the button twice for the changes in XML to show up.
If you need more info that's fine but I don't want to make things so
longwinded to put people off! Regards, Chris.
 
Hi.
This is probably not the best solution, but if you must post your page one
more time you can use a javascript.
Here is an example:
Protected WithEvents myBody As System.Web.UI.HtmlControls.HtmlGenericControl
(Remember to put runat="server" in your body tag.)

Put this code in your buttons click event.
myBody.Attributes.Item("onLoad") = "document.forms[0].submit()"

Clear the onLoad event in page_load to avoid the form being posted every
time the page loads.
myBody.Attributes.Item("onLoad") = ""

Hope this helps,
Shawn
 
Hi Chris,

Your description is still a bit vague but I think I got your scenario now.
What you're trying to do goes against the web form architecture. The logic
that will take the modified value from the Click event and will do anything
to the XML file should be placed in an event like PreRender, trying to have
this logic as early as the Init event is not good as this event and the Load
one are there mostly to recreate the state the page previously had.
Then -once the state is the same it was before postback- event will be
processed and its there where you have a chance to modify anything, just
before the page renders again.

This is usually a bit difficult to grasp at first.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Read my weblog:
Followers of the IHttpHandler
http://clariusconsulting.net/vga
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top