Hi all
Can anyone tell me how to add a click event for a user control page
dynamically???
Thanx
Krish. 6 3202
I use below code to add a dynamically control and += an event for it
override the OnInit event
protected override void OnInit(EventArg s e)
{
btnGo=new Button();
btnGo.ID="btnGo ";
btnGo.Text="Go" ;
btnGo.CssClass= "Button";
this.Controls.A dd(btnGo);
this.btnGo.Clic k += new System.EventHan dler(this.btnGo _Click);
base.OnInit (e);
}
<co*******@gmai l.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. . Hi all
Can anyone tell me how to add a click event for a user control page dynamically???
Thanx Krish.
Dear Seraph Jiang ,
I should not create and use the button in my
appln.If i click anywhere in the User control ,it ll do something.The
user control contains 4 labels only... Now plz tell me is any other way
(without button creation) to do this task??
Thanx
Krish.
So, if I understand you, you want to respond to the "Click" event of
the UserControl itself.
If that's so, Seraph just showed you how to do it for a dynamically
created button. Just do exactly the same thing, substituting your
UserControl for Seraph's Button.
If I misunderstand, then maybe you could post the code to your
UserControl and explain in more detail what it is you want to do.
Dera Bruce,
Yes, I want to respond to the Click event of the UserControl
itself.If I click on the User Control it ll do some action...Plz tell
me How to do??
Dear Bruce,
Yes, I want to respond to the Click event of the UserControl
itself.If I click on the User Control it ll do some action...Plz tell
me How to do??
Well, just do exactly what Seraph showed you, but with your
UserControl:
MyUserControl user = new MyUserControl() ;
user.ID="user";
this.Controls.A dd(user);
user.Click += new System.EventHan dler(this.user_ Click);
and then, somewhere in your code:
private void user_Click(obje ct sender, System.EventArg s e)
{
... do whatever you want when the butotn is clicked ...
} 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: Diane |
last post by:
Hi-
I've been struggling with this problem and none of the fixes posted
seem to help out at all. Yet, it seems like such a simple problem...
I have a DataGrid, and load it up with data on page load. In my
EditCommand event handler I set the editItemindex. All good. Except,
the user needs to click twice to get the DataGrid to become editable.
It's obvious to me (perhaps worngly) that ASP.NET is storing the data
|
by: Kjell Kristiansson |
last post by:
I have not been able to figure out how to catch the click event from a
button that is added dynamically to a table. In priciple the process is as
follows:
When I first create the page I analyse data and if appropriate:
- add one or more row to a table in the webform
- add cells to the rows
- add a button (myButton) where the user can change some settings.
- enable/disable some other buttons to the form
This is all done in a function...
|
by: conckrish |
last post by:
Hi all,
Can anyone tell me how to add Click event for dynamically
created User control page ?? I have a user control page in datagrid
cell. when i click this user control page it ll redirect to another
page. plz tell me how to add click event ???
Thanx.
|
by: hlubocky |
last post by:
I thought I had a good grasp of the problem related to dynamically
creating controls, but it appears that as my application grew in
complexity, the problem has resurfaced. As I understand it, in order
for a dynamically created control to persist its state, it needs to be
created and loaded into the page control hierarchy before the viewstate
is loaded.
The proposed solution, and that which I have been using, has been to
create all of...
| |
by: Demetri |
last post by:
I have created a web control that can be rendered as either a linkbutton or a
button. It is a ConfirmButton control that allows a developer to force a user
to confirm if they intended to click it such as when they do a delete.
Everything is great. By and large it will be used in my repeater controls
using the command event when the user clicks on it and so that event is
working great.
My issue is the Click event. When the control is...
|
by: Bob |
last post by:
Hi,
I'm working with VWD and i defined programmatically a button (in
code-behind) with an ID. So I expect to see beside "Page Events" and "Form1"
my button "b1" in order to use the Click event. But it doesnt' appear. After
saving the code-behind file, i only see "Page Events" and "Form1".
If i define the button declarativally, i see it. But i need to define it
programmatically.
Can anybody tell me how to do? I also tried with...
|
by: Amoril |
last post by:
I've read quite a few different message on various boards and for some
reason I'm still having trouble wrapping my head around this viewstate
maintenance and trying to get these dynamically created link buttons
to stay wired up to their click events.
I have what is basically a simply survey question generation page. The
page first displays a few static fields and a dropdownlist of various
options for the user to select. When the user...
|
by: =?Utf-8?B?TWFyaw==?= |
last post by:
Hi, I have built a custom control button which inherits from WebControl and
implements IPostBackEventHandler. The control also declares an event Click
and provides a method OnClick which invokes the registered delegate. All is
fine with my control until I try to add it to the page dynamically in a code
behind event handler and wire-up the click event using the normal syntax such
that;
protected void btnNew_Click(object sender, EventArgs...
|
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: 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: 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: 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: 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...
| |