473,464 Members | 1,732 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Adding eventhandler to control

Hi,

How can I add an even handler to a control that is not situated on the main
page (it's situated in the repeater).
How do I rewrite this to make it work ?

Thanx, Neven

---------------------------------------------

this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
Nov 16 '05 #1
4 4297
Neven,

You would have to get the instance of the control in the repeater, and
set the event handler like you would any other control.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Neven Klofutar" <ne************@public.srce.hr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

How can I add an even handler to a control that is not situated on the main page (it's situated in the repeater).
How do I rewrite this to make it work ?

Thanx, Neven

---------------------------------------------

this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);

Nov 16 '05 #2
Hi Neven,
You can do it in the aspx file itself, take a look at the line below, this
is declared inside a DataGrid but it should work on any list control,
including the repeater.
If this is of not help , just post the piece of code and the event you are
trying

<asp:imagebutton Visible="True" runat="server" ToolTip="Save Changes"
OnClick="UpdateItem" ImageUrl="images/ico_ok.gif" ID="Imagebutton2" />

See how I declare the OnClick handler.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Neven Klofutar" <ne************@public.srce.hr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

How can I add an even handler to a control that is not situated on the main page (it's situated in the repeater).
How do I rewrite this to make it work ?

Thanx, Neven

---------------------------------------------

this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);

Nov 16 '05 #3
I really don't know how to maki it work, I tried everything ...
I have btnSearch button that works perfectly and it's situated on the mail
page, and I have btnPlanetName that is situated in the header template of
the repeater that I can't make it to work ...
Please help, I'm getting desperate ...

Here's part of my code ...
-------------------
<asp:button id=btnSearch runat="server" ForeColor="White" BorderWidth="1px"
BorderStyle="Solid" BorderColor="Black" BackColor="Maroon" Text="Search
!"></asp:button>

<asp:repeater id=rpScan runat="server" EnableViewState="False">
<HeaderTemplate>
<table border='0' width='100%'>
<tr>
<th>
<asp:Button Runat=server ID=btnPlanetName Text='Planet Name'
BackColor='darkgreen' BorderWidth='0' ForeColor='white' Font-Size='11px'
Font-Bold=True Font-Underline=True style='CURSOR: hand'
OnClick="btnPlanetName_Click"></asp:Button>
</th>
Nov 16 '05 #4
Thanx everyone for your help ...
I'm suck an idiot !!!!

I turned off viewstate on the repeater, so ... :(

SORRY !!!!

Neven
"Neven Klofutar" <ne************@public.srce.hr> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I really don't know how to maki it work, I tried everything ...
I have btnSearch button that works perfectly and it's situated on the mail
page, and I have btnPlanetName that is situated in the header template of
the repeater that I can't make it to work ...
Please help, I'm getting desperate ...

Here's part of my code ...
-------------------
<asp:button id=btnSearch runat="server" ForeColor="White" BorderWidth="1px" BorderStyle="Solid" BorderColor="Black" BackColor="Maroon" Text="Search
!"></asp:button>

<asp:repeater id=rpScan runat="server" EnableViewState="False">
<HeaderTemplate>
<table border='0' width='100%'>
<tr>
<th>
<asp:Button Runat=server ID=btnPlanetName Text='Planet Name'
BackColor='darkgreen' BorderWidth='0' ForeColor='white' Font-Size='11px'
Font-Bold=True Font-Underline=True style='CURSOR: hand'
OnClick="btnPlanetName_Click"></asp:Button>
</th>
.
.
.

public class searchOpensNEW : System.Web.UI.Page {

.
.
protected System.Web.UI.WebControls.Button btnPlanetName;
private void InitializeComponent() {
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
}

public void btnPlanetName_Click(object sender, System.EventArgs e) {
lblSortName.Text = "name";

if (lblSortOrder.Text == "DESC") {
lblSortOrder.Text = "ASC";
} else {
lblSortOrder.Text = "DESC";
}
search4Opens("name", lblSortOrder.Text);
}
public void search4Opens(string sortName, string sortOrder) {
string stProc = "GalaxyScanFinder";
SqlParameter[] arrParams =
SqlHelperParameterCache.GetSpParameterSet(UtilityD B.getConnectiongString(), stProc);
arrParams[0].Value =
UtilityGeneral.toDatumSQLFull(DateTime.Parse(cmbTi me1.SelectedItem.Value)); arrParams[1].Value =
UtilityGeneral.toDatumSQLFull(DateTime.Parse(cmbTi me2.SelectedItem.Value)); arrParams[2].Value = Int32.Parse(txtLand1.Text);
arrParams[3].Value = Int32.Parse(txtLand2.Text);
arrParams[4].Value = chkOpensOnly.Checked.ToString();
arrParams[5].Value = sortName;
arrParams[6].Value = sortOrder;

SqlDataReader drScan =
SqlHelper.ExecuteReader(UtilityDB.getConnectiongSt ring(),
CommandType.StoredProcedure, stProc, arrParams);

rpScan.DataSource = drScan;
rpScan.DataBind();

UtilityDB.drClose(drScan);
}
private void btnSearch_Click(object sender, System.EventArgs e) {
search4Opens("land2", "desc");
}
}

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote in message news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi Neven,
You can do it in the aspx file itself, take a look at the line below,

this
is declared inside a DataGrid but it should work on any list control,
including the repeater.
If this is of not help , just post the piece of code and the event you

are
trying

<asp:imagebutton Visible="True" runat="server" ToolTip="Save Changes"
OnClick="UpdateItem" ImageUrl="images/ico_ok.gif" ID="Imagebutton2" />

See how I declare the OnClick handler.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Neven Klofutar" <ne************@public.srce.hr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

How can I add an even handler to a control that is not situated on the

main
page (it's situated in the repeater).
How do I rewrite this to make it work ?

Thanx, Neven

---------------------------------------------

this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);



Nov 16 '05 #5

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

Similar topics

0
by: Chris Millar | last post by:
I have a user control that i wish to extend to change the date when the user selects the numeric up down button. The code explains itself, hope someone can help. any ideas appreaciated.. ...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
by: Tim Marsden | last post by:
Hi, This is what I am doing, please comment if this is the correct way. I need to add controls to a form dynamically. Within the Page_Load event (is not Postback) I run a routine to create the...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
6
by: Just Me | last post by:
I need to create a library sub that adds event handlers to a control. Public Shared Sub AddEvent(ByVal qq As Control, By?? ControlMouseMove As ??) So I need to pass the address of the handler or...
3
by: Bruce Wood | last post by:
Maybe I'm going nuts, but I was so sure that adding the same method more than once to a delegate would result in only one entry on the delegate's call list: this.UpdateEnd += new...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
7
by: Rotsey | last post by:
Hi, I have a interface that I use for a form so I can pass the form to another object. How do I add the Paint event to the interface and subsequently handle the paint event in my other...
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
Oralloy
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,...
1
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...
0
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...
0
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...
0
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 ...

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.