E
Earl Teigrob
I have run into a situation where I need to run the !IsPostBack code under
one circumstance, even if it is a postback. Something that may complicate
matters more is that this is a double postback event.
I have a filemanager type application that allows me to dynamically create a
new folder on the web server. After the new folder is created, I need to
reread the directory and display all the current folders in this directory
to the user.
If I load all of the !IsPostBack code on every page load, everything works
fine but it is just so inefficient.
The code in the create folder event looks like this:
-------------
Directory.CreateDirectory(NewFolderString);
StatusMessage.Text="Folder " + NewFolderName.Text + "has been created";
ViewState["ExecNonPostBack"]="true";
Page.RegisterStartupScript("PostBack","<Script
Language=\"Javascript\">document.forms[0].submit();</Script>"); //do double
post back
-------------
and the code in the page load event looks like this
-------------
string s = (string)ViewState["ExecNonPostBack"];
if (!(Page.IsPostBack)||(s=="true"))
{ ... display folders to the user}
--------------
In my attempt to use the state bag to determine if a code should be
executed, the view state variable set in the create folder event does not
carry to the page load event.
One thing to note is that the create folder event is in a user control that
is loaded into the page.
So, How do i force the page to run the IsPostBack code during a postback
ONLY when I want it to???
Thanks
Earl
one circumstance, even if it is a postback. Something that may complicate
matters more is that this is a double postback event.
I have a filemanager type application that allows me to dynamically create a
new folder on the web server. After the new folder is created, I need to
reread the directory and display all the current folders in this directory
to the user.
If I load all of the !IsPostBack code on every page load, everything works
fine but it is just so inefficient.
The code in the create folder event looks like this:
-------------
Directory.CreateDirectory(NewFolderString);
StatusMessage.Text="Folder " + NewFolderName.Text + "has been created";
ViewState["ExecNonPostBack"]="true";
Page.RegisterStartupScript("PostBack","<Script
Language=\"Javascript\">document.forms[0].submit();</Script>"); //do double
post back
-------------
and the code in the page load event looks like this
-------------
string s = (string)ViewState["ExecNonPostBack"];
if (!(Page.IsPostBack)||(s=="true"))
{ ... display folders to the user}
--------------
In my attempt to use the state bag to determine if a code should be
executed, the view state variable set in the create folder event does not
carry to the page load event.
One thing to note is that the create folder event is in a user control that
is loaded into the page.
So, How do i force the page to run the IsPostBack code during a postback
ONLY when I want it to???
Thanks
Earl