How do I force a postback in the codebehind?

  • Thread starter Thread starter aaa
  • Start date Start date
A

aaa

I am checking if a certain object is null and if it is I need to go back to
ther server and get this object can I force a postback in the code behind
and if so how?
 
You need to call a javascript method. myForm.submit() will do.
location.reload() also will. Why do you want to do it in the code behind?
Why not to put a few lines if javascript in the .aspx page?

Eliyahu
 
your question makes no sense. codebehind is server processing, so there is
no need of a postback, you are already there.


-- bruce (sqlwork.com)
 
aaa said:
I am checking if a certain object is null and if it is I need to go back to
ther server and get this object can I force a postback in the code behind
and if so how?


I'm not really sure what you mean, but if your in the codebehind there is no
way to execute postback but there is trick there by rendering a javascript
that will resubit the form:

....
....

if(requirePostback)
{
Response.Write("<script>document.forms[0].submit();</script>");
}

...
....

the statement above will reexecute submit.
 

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