473,587 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using IsPostBack in Page_Load of dynamically added control

DC
Hi,

I am dynamically adding a usercontrol that uses "this.IsPostBac k" in
Page_Load to decide whether it must populate some of it's inner
controls or not. Since I am adding the usercontrol to the page at
runtime (on response to a click event), IsPostBack is always false and
the inner controls never get populated.

I changed "IsPostBack " to "IsInitial" now, using this property:

public bool IsInitial
{
get
{
if (ViewState["IsInitial"] == null)
{
ViewState["IsInitial"] = false;
return true;
}
return false;
}
}

I don't think this is the way to do it. If the sourcecode of the
control is not available, I cannot add the usercontrol dynamically
without running into this problem. Is there a way to explicitly set
"IsPostBack " of the control to "true" from outside somehow? I thought
using "if (!IsPostBack)" to init controls in Page_Load is recommended.

Kind regards
DC
Nov 30 '07 #1
0 1265

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

Similar topics

11
1387
by: suzy | last post by:
hi, i have an aspx page with a button. if i step through my code when i click the button then it calls the button_Click event which is what i want. but i need to redirect the page to another aspx page when this button is clicked so i dont want to waste time rendering the same page before redirecting, so i put the following code in, but...
6
16038
by: DotNetGruven | last post by:
I've got a page that does a search... There is an ImageButton on it that allows the user to reset the search. The Click Handler for the button clears out the Data and then redirects to the same page with Response.Redirect("Search.Aspx", true); Sometimes the code in Page_Load within the IsPostBack part of the if statement runs and...
1
3013
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am have facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also...
1
2562
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made...
10
2485
by: George G. | last post by:
Hi there, I am busy writing a new asp.net application and I am reusing some of my existing asp functions and methods in a user control. I need access to session, request and response in some of the functions and I can't find out how to do it. Here is an example of what I do and I get the following Cannot refer to an instance member of a...
4
1675
by: TJ | last post by:
Hi, There is one aspx web page that contains usercontrol. In aspx page and usercontrol , there is each submit button... Here is what I want... I want to process something depending on each page's IsPostBack property... For exmple.... when I click the submit button which is in usercontrol, ASPX page should
6
1459
by: RA | last post by:
btnAdd_Click does not get hit; if I have IsPostBack check in Page_load. If I don't have IsPostBack check; I am able to debug through btnAdd_Click. If I don't look for IsPostBack then it re-populates the table before doing anything; which I don't want. Following is the code. private sub page_load(.......) ' if ispostback = false then...
4
3344
by: sebastien | last post by:
Hi, In page_load : If Not Page.IsPostBack Then Dim myUC As UserControl = LoadControl("ficheProspects.ascx") myUC.ID = "FicheProspects1" End If In another Sub i need to find my control :
8
2681
by: John Austin | last post by:
I need to understand why if I add a control and use AddHandler to connect its click event, it will work in Page_Load, but not in a Button_Click. The idea is that the user types some data, presses the button, gets a list of results (each with a LinkButton) and can then press one of the link buttons to get further information. The newly added...
0
7843
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8339
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5712
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2347
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1452
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.