473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

LoadControl and the PostBack problem

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
Jul 28 '08 #1
2 2559
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
Jul 28 '08 #2
On Jul 28, 10:24*pm, Munna <munna...@gmail.comwrote:
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!
Jul 29 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MrMike | last post by:
I have a datagrid containing a drop-down-list. The datagrid contains Edit,Update,Cancel buttons and respective events. Whenever I make a change to one particular field (a drop-down-list in...
1
by: Joseph Luner | last post by:
I am having problem postback, (code shown below) the variable "my_str" is lost after clicking the "submit" button. Isn't it suppose to display "changed" after posting back? Is there anyway I...
1
by: Frankieboy | last post by:
I believe I've got a postback problem on our site. The strange thing is that everything works fine on my developing version, but not on the production site. I'm wondering if there may be different...
0
by: bill yeager | last post by:
I have a simple button and textbox on a webform with a RequiredFieldValidator tied to the textbox control. The problem is that a postback never occurs on the webform by clicking the button even...
0
by: phl | last post by:
hello, I have an input control which saves a file user specifies. Like this : SaveCon.PostedFile.SaveAs(sDocPath) This cause a postback which presents a problem as I want this to happen in my...
4
by: Daniel Groh | last post by:
I have two controls in my webform, BUT....one comes from a user control and the other comes from another user control, both with post back! How can i work just with one PostBack ? if(PostPack...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
9
by: Alper OZGUR | last post by:
Hi; In my code i'm checking some conditions and if the condition fails i want to postback the page. Tried using the below methods but the when form is loaded the postback status is false.. how can...
0
by: =?Utf-8?B?U3VzaGlTZWFu?= | last post by:
Hello. I have some problem and really need a answer why it happens. I have asp.net framework 2 site and I use 2 clusters (NLB). They both use the same network path to source code, the same...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.