Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > LoadControl and the PostBack problem

Reply
Thread Tools

LoadControl and the PostBack problem

 
 
jack
Guest
Posts: n/a
 
      07-28-2008
Hi folks,
Consider a page consisting of a treeview, and a panel. The panel is
supposed to be refreshed based on treeview node selection.

protected void tree_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode node = this.tree.SelectedNode;
if (node != null)
LoadMyControls(node);
}

Where LoadMyControls simply loads the associated control based on the
node and adds it to the panel's controls collection. The loaded
control, on the other side, is supposed to have a DropDownList
control, which based on user selection updates a gridview. However,
when a new item is selected in the combo box, the entire panel is
vanished and a blank page appears.

AFAIK, This indicates that the control has to be loaded again, hence,
the LoadMyControls has to be invoked. So I added the following lines
to the Page_Load function:

Boolean isTreeThePostBackSource =
this.scriptManager.AsyncPostBackSourceElementID.Eq uals(this.tree.UniqueID);
if (!isTreeThePostBackSource)
{
TreeNode node = this.tree.SelectedNode;
if (node != null)
LoadMyControls(node);
}

This way, everything works fine.

However, I've noticed that IsPostBack is always true, when the User
Control gets loaded. So, I've got no mechanism to learn whether the
user control should be initialized for the first time. How am I
supposed to do this?

Any help would be highly appreciated,

Thanks
Jack
 
Reply With Quote
 
 
 
 
Munna
Guest
Posts: n/a
 
      07-28-2008
Hi,

"However, I've noticed that IsPostBack is always true,"

Page.IsPostback Is false when the page is requested for the first
time...
after each subsequent submit from any control the value is this
variable is false

regards

Munna
 
Reply With Quote
 
 
 
 
jack
Guest
Posts: n/a
 
      07-29-2008
On Jul 28, 10:24*pm, Munna <munna...@gmail.com> wrote:
> Hi,
>
> "However, I've noticed that IsPostBack is always true,"
>
> Page.IsPostback Is false when the page is requested for the first
> time...
> after each subsequent submit from any control the value is this
> variable is false
>
> regards
>
> Munna


That's not the case when you use the LoadControl to load a user
control dynamically!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing and rendering user controls via LoadControl and RenderControl Deane ASP .Net Building Controls 0 09-03-2007 08:47 PM
LoadControl() problem =?Utf-8?B?UmV4VmFu?= ASP .Net 1 08-31-2004 05:25 AM
LoadControl and PostBack Issue Craig Buchanan ASP .Net 1 02-20-2004 04:19 PM
LoadControl and PostBack Craig Buchanan ASP .Net 0 02-20-2004 02:55 PM
LoadControl and PostBack Craig Buchanan ASP .Net 1 02-12-2004 09:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57