I have am dynamically loading a web user control based on the click of a tab
strip
I load the default control for the first tab in the page load event after
checking page is not postback. After that the controls are loaded/unloaded
based on the SelectionChange d event for the tab strip and again in Page load
because with a dynamic load viewstate has to be reloaded. I have a datalist
in the user control and I am trying to create the delegate so the parent can
handle the click of the edit button in the user control. Honestly I am not
very good at event delegation the code complies but I never get the command
to execute on the parent
in the child control site.ascx I set up the datalist public event with
code below
public partial class Site : System.Web.UI.U serControl
{
public delegate void myItemCommand(o bject source,
DataListCommand EventArgs e);
public event myItemCommand dlSiteItemComma nd;
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{ }
protected void dlSite_ItemComm and(object source,
DataListCommand EventArgs e)
{
if (dlSiteItemComm and != null)
dlSiteItemComma nd(source, e);
}
protected void Page_Load(objec t sender, EventArgs e)
{ //get the data and fill the datalist }
in the parent (Detail) I try to bind to the event in the Site.ascx When
the page loads in the parent the procedure LoadUserControl ()
is called and in it after I dynamically load the correct control, I caste
the generic control to an instance of Site so I can see the public event I
created. Thats where I have got it wrong I am SOOOOO confused. The binding
does not work when I click the edit button in the child datalist I never
break into the event that is bound on the parent Below is parent code.
Please I not this is too long an explanation but I have been trying and
reading a long time.
Cindy
public partial class Detail : System.Web.UI.P age
{
private string LastLoadedContr ol
{
get
{
return ViewState["LastLoaded "] as string;
}
set
{
ViewState["LastLoaded "] = value;
}
}
private void LoadUserControl ()
{
string controlPath = LastLoadedContr ol;
if (!string.IsNull OrEmpty(control Path))
{
PlaceHolder1.Co ntrols.Clear();
UserControl uc = (UserControl)Lo adControl(contr olPath);
if (controlPath == "Site.ascx" )
{
Site ucSite = (Site)uc;
ucSite.dlSiteIt emCommand += new
Site.myItemComm and(ucSite_dlSi teItemCommand);
}
PlaceHolder1.Co ntrols.Add(uc);
}
}
void ucSite_dlSiteIt emCommand(objec t source, DataListCommand EventArgs e)
{
(source as DataList).EditI temIndex = e.Item.ItemInde x;
(source as DataList).DataS ource = dsTunnel;
(source as DataList).DataB ind();
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}
private void InitializeCompo nent()
{}
protected void Page_Load(objec t sender, EventArgs e)
{
if(!(Page.IsPos tBack))
{
string controlPath = null;
controlPath = "Site.ascx" ;
LastLoadedContr ol = controlPath;
LoadUserControl ();
}
LoadUserControl ();
}
private void ts_SelectionCha nged(object sender,
JQD.TabStrip.Se lectionChangedE ventArgs e)
{
int TabPos = e.TabPosition;
ActiveTab = TabPos;
string controlPath = string.Empty;
switch (TabPos)
{
case 0:
controlPath = "Site.ascx" ;
LastLoadedContr ol = controlPath;
LoadUserControl ();
break;
case 1:
break;
}
--
cindy 0 1908 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Earl Teigrob |
last post by:
PROBLEM:
When a user control is loaded into a PlaceHolder control more than once, the
events do not fire on the first click of a control on the dynamically loaded
user control. In other words, the first time the control is dynamically
loaded, everything works fine. After that, if the control is loaded again
from the page button event handler, the user controls events fail to fire on
the first click
NOTE: I (believe I) am rebuilding all...
|
by: kw |
last post by:
My aspx dynamically loads an ascx into a placeholder. The ascx has an
event. When I click on the submit linkbutton in the ascx, the event does
not fire. But if I click it a second time, it fires.
I put in tracing, and the OnInit (which loads the event handler) is executed
on the initial load and also on the 2nd. It just makes no sense to me. Any
ideas?
Thanks a zillion!!
|
by: EvelynAnd Ethan |
last post by:
Hi,
ItemCommand event not firing from a dynamic user control ,WHERE A
DATAGRID HAS BUTTON,when i click on the linkbutton first time the
itemcommand event doesnt fire,second time event fires up
any answers??
Regards,
|
by: Hans Merkl |
last post by:
Hi,
I am trying to use a user control as EditItemTemplate in a DataList. It
loads fine but I can't figure out how to bind to the data of the DataList.
Here is what I have got so far:
//Page_load of my user control
protected void Page_Load(object sender, EventArgs e)
{
IDataItemContainer DataContainer = this.Parent as
|
by: Jason Chan |
last post by:
I have a paging datalist which show a list of thumbnail.
Above the datalist there is a dropdown to jump to different paging.
On Page_load, I bind the datalist according to the current page.
On the same time, I have to generate a dynamic javascript to load the image
in the datalist to an javascript array
So I use Page.RegisterStartupScript to insert the script just before the
closing form tag.
| |
by: Luis Arvayo |
last post by:
Hi,
In c#, I need to dynamically create types at runtime that will consist of
the following:
- inherits from a given interface
- will have a constructor with an int argument
|
by: TS |
last post by:
I am creating a User control and i create some dynamic controls in the init
handler. one of the controls is a custom validator which i assign a
serverValidate event handler. I usally always do my controls as custom
server controls and don't understand why this event won't fire.
I figured if the creation of the control was in the init, it would be
initialized and have its event handlers set up, then after Load, the control
would call its...
|
by: davidr |
last post by:
Hi,
I have a panel that I load user Control in no problem. The problem
arrises when I do a post back on one of these user controls. I have
button it does a click event. In this click event I will do some
database updates, then I will use reflection to call a method in the
parent (this.page) to load the new user control. Its at this point
after it loads the new user control that it throws the error "The
control must be placed inside...
|
by: CMELLO |
last post by:
I have am dynamically loading a web user control based on the click of
a tab strip
I load the default control for the first tab in the page load event
after checking page is not postback. After that the controls are
loaded/unloaded based on the SelectionChanged event for the tab strip
and again in Page load because with a dynamic load viewstate has to be
reloaded. I have a datalist in the user control and I am trying to
create the...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |