How do I force a postback in the codebehind?

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?
 
E

Eliyahu Goldin

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
 
B

Bruce Barker

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


-- bruce (sqlwork.com)
 
G

Guest

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top