Hi!
Could someone please help me with the following; I have a WebControl that
basically looks like this:
public class LeftMenu : System.Web.UI.W ebControls.WebC ontrol
{
private string m_CurrentNodeId = string.Empty;
public string CurrentNodeId
{
get
{
return m_CurrentNodeId ;
}
}
private void Page_Load(objec t sender, System.EventArg s e)
{
...
}
private void custExpand_Clic k(object sender,EventArg s e)
{
m_CurrentNodeId = e.SomeStringVal ue;
}
}
Which I'm loading into my parent page like this:
public class Default
{
protected LeftMenu mmLeftMenu;
protected System.Web.UI.W ebControls.Pane l pnlLeftMenu;
public string CurrentNodeId = String.Empty;
private void Page_Load(objec t sender, System.EventArg s e)
{
mmLeftMenu =
(LeftMenu)LoadC ontrol(pnlLeftM enu,@"~\Control s\LeftMenu.ascx ");
CurrentNodeId = mmLeftMenu.Curr entNodeId;
}
}
Problem is CurrentNodeId in Default never gets the value of
mmLeftMenu.Curr entNodeId, because custExpand_Clic k gets fired after the
Page_Load in Default. How should I set things up, so that I can get the
value of mmLeftMenu.Curr entNodeId in Default???
Thanks. 3 1455
What you have here is an issue of sequence. This problem is fairly common,
esp. among newer developers of ASP.Net, as the .Net SDK seems to have a lot
of samples using the Page_Load event. In point of fact, however, the
system.Web.UI.P age class is derived from System.Web.UI.C ontrol, and every
Control has about a dozen event handlers that you can wire up, all of which
occur in a specific sequence. To find out more about the sequence of events,
see: http://msdn.microsoft.com/library/de...nLifecycle.asp
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
"spmm#" <sp******@yahoo .com> wrote in message
news:41******** *************** @news.xs4all.nl ... Hi!
Could someone please help me with the following; I have a WebControl that basically looks like this:
public class LeftMenu : System.Web.UI.W ebControls.WebC ontrol { private string m_CurrentNodeId = string.Empty;
public string CurrentNodeId { get { return m_CurrentNodeId ; } }
private void Page_Load(objec t sender, System.EventArg s e) { ... }
private void custExpand_Clic k(object sender,EventArg s e) { m_CurrentNodeId = e.SomeStringVal ue; } }
Which I'm loading into my parent page like this:
public class Default { protected LeftMenu mmLeftMenu; protected System.Web.UI.W ebControls.Pane l pnlLeftMenu; public string CurrentNodeId = String.Empty;
private void Page_Load(objec t sender, System.EventArg s e) { mmLeftMenu = (LeftMenu)LoadC ontrol(pnlLeftM enu,@"~\Control s\LeftMenu.ascx "); CurrentNodeId = mmLeftMenu.Curr entNodeId; } }
Problem is CurrentNodeId in Default never gets the value of mmLeftMenu.Curr entNodeId, because custExpand_Clic k gets fired after the Page_Load in Default. How should I set things up, so that I can get the value of mmLeftMenu.Curr entNodeId in Default???
Thanks.
You might need to make your webcontrol raise an event when custExpand_Clic k
is hit, which the page can hook into...somethin g like
public class LeftMenu: WebControl{
public event CommandEventHan dler NodeClick;
...
private void custExpand_Clic k(object sender,EventArg s e) {
m_CurrentNodeId = e.SomeStringVal ue;
if (this.NodeClick != null){
CommandEventArg s ev = new CommandEventArg s("clicked",
m_CurrentNodeId );
this.NodeClick( this, ev);
}
}
}
the in your page, you can:
page_load{
mmLeftMenu =
(LeftMenu)LoadC ontrol(pnlLeftM enu,@"~\Control s\LeftMenu.ascx ");
mmLeftMenu.Node Click += new CommandEventHan dler(mmLeftMenu _NodeClick);
}
private void mmLeftMenu_Node Click(object sender, CommandEventArg s e) {
Response.Write( "node value: " + e.CommandArgume nt);
}
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"spmm#" <sp******@yahoo .com> wrote in message
news:41******** *************** @news.xs4all.nl ... Hi!
Could someone please help me with the following; I have a WebControl that basically looks like this:
public class LeftMenu : System.Web.UI.W ebControls.WebC ontrol { private string m_CurrentNodeId = string.Empty;
public string CurrentNodeId { get { return m_CurrentNodeId ; } }
private void Page_Load(objec t sender, System.EventArg s e) { ... }
private void custExpand_Clic k(object sender,EventArg s e) { m_CurrentNodeId = e.SomeStringVal ue; } }
Which I'm loading into my parent page like this:
public class Default { protected LeftMenu mmLeftMenu; protected System.Web.UI.W ebControls.Pane l pnlLeftMenu; public string CurrentNodeId = String.Empty;
private void Page_Load(objec t sender, System.EventArg s e) { mmLeftMenu = (LeftMenu)LoadC ontrol(pnlLeftM enu,@"~\Control s\LeftMenu.ascx "); CurrentNodeId = mmLeftMenu.Curr entNodeId; } }
Problem is CurrentNodeId in Default never gets the value of mmLeftMenu.Curr entNodeId, because custExpand_Clic k gets fired after the Page_Load in Default. How should I set things up, so that I can get the value of mmLeftMenu.Curr entNodeId in Default???
Thanks.
Thanks to both of you! Karl your solution works perfectly. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
I am looking for a easy way to trap an Exception that may occurr in any one
of 30 child web controls to be trapped at the topmost parent WebUser control
or Page Level. I have tried variations of setting the Error event handler
for the topmost parent WebUser control that I want to handle the error to no
avail.
Sample code from the MSDN seems to imply that this can be done but it can
only be taken care of at the same user control level as...
|
by: eagle |
last post by:
How do I access a control, like a placeholder, from another page, or another
user control that may be on the same page.
For instance, I have a web page with 2 user controls. One user controls
contains a placeholder to that will contain any error messages to be
displayed. If the first user control creates an error, I want to be able to
push that error to the 2nd control to display it at the placeholder.
I have tried
Dim ctrlError as...
|
by: Jeremy Chapman |
last post by:
I have a property will an array of webcontrols.
The control features a custom property editor which can add and remove web
controls to the array, but how do I persist the informtion by serializing it
to the aspx page?
For example, right now, here is what the html looks like when I drag my
control on to the page and add some web controls to the ControlList
property:
|
by: David Hearn |
last post by:
I have a property in a user control that I am setting:
Private strPageName as String
Public Property PageName() as String
Get
Return strPageName
End Get
Set(byVal Value as String)
strPageName = Value
End Set
|
by: Steve |
last post by:
I'm trying to iterate over all the form controls in my MasterPages content
page. Basically, I've got dropdowns, textboxes, etc that I want to format
in Page_Load()
I've added this code to my Page_Load() event
<code>
private void ConfigureFormControls()
{
Color borderColor = ColorTranslator.FromHtml("#F5F5F5");
Color fontColor = borderColor;
| |
by: Charles Zhang |
last post by:
I created a custom server control that derives from WebControl. I found
Parent and Page property are null for the control I created. But Parent
is a readonly property so that I have no way to assign it a proper value.
By the way, I did no create a constructor for my custom control. I did
not override OnInit() method as well.
Could some one point out what I am doing wrong.
|
by: shapper |
last post by:
Hello,
I have a class where I created various controls.
One of the controls have a property which is a generic list of
WebControl.
Then in web site page I have something like:
Dim a As New MyNamespace.ListItem
a.WebControls.Add(tbName)
a.WebControls.Add(lLabel)
|
by: nottarealaddress |
last post by:
I'm trying to get my feet wet in VB2005 (our new standard at work
after officially stopping new development in VB6 about a month ago).
I'm working with a simple sql 2005 table of 50 entries, one for each
state. Each entry contains Name, postal abbreviation, etc. Just simple
stuff to understand the mechanisms, syntax, etc.
I'm now to the point where I've got a Master MDI form that opens one
or more types of forms, I'm able to edit/save...
|
by: =?Utf-8?B?bXVzb3NkZXY=?= |
last post by:
Hi guys
I'm trying to make my code as streamlined as possible, and add CSS file
references dynamically when they are required, for example, if a page
contains a webcontrol, then the related CSS file is added by the webcontrol.
This prevents me having to remember to add the CSS file to the page if I use
a certain webcontrol.
I have a MasterPage with an array of StyleSheets, and a public function for
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |