473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

anyone?? :o( buttons and arguments

hi there, I am using c#, not quite sure how to get an argument into an event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click event.
But I want to send a value to the click event (an id to be passed in an url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif" height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.

Nov 18 '05 #1
8 1420
it the CommandName and CommandArgument properties.

-- bruce (sqlwork.com)

"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C9**********************************@microsof t.com...
| hi there, I am using c#, not quite sure how to get an argument into an
event.
|
| protected void btnRedirect_Click (object sender, eventargs e) {
|
| go to url newpage?id=[id i passed]
|
| }
|
|
| i know sender is whatever control invoked this code (e.g. button) but not
| sure what the eventargs is for. I have a button which performs a click
event.
| But I want to send a value to the click event (an id to be passed in an
url
| redirection). How do I put this string into the argument list of the click
| event?
|
| I am also trying to put the id into the click in the html and this is
| returning an error (asp server control not formed). The value I want to
pass
| comes from an asprepeater. what am i missing in the following?
|
| <asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif"
height="17px"
| width="48px" onclick="btnViewClient_Click(<%#
| DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>
|
| Thank you.
|
Nov 18 '05 #2
Try doing:

<asp:ImageButton id="btnNext" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>' .... />

then in your code.

string clientId = ((ImageButton)sender).CommandArgument;
Response.Redirect("newPage.aspx?id=" + clientId, true);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C9**********************************@microsof t.com...
hi there, I am using c#, not quite sure how to get an argument into an event.
protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click event. But I want to send a value to the click event (an id to be passed in an url redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to pass comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif" height="17px" width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.

Nov 18 '05 #3
The Event is raised by the object which raised it. As you didn't define the
class, you have no control over what arguments are passed by it. Therefore,
the solution to passing an argument into an Event is to create an object
that does that. For example, you could create a custom Server Control that
inherits Button, and does its' events differently.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C9**********************************@microsof t.com...
hi there, I am using c#, not quite sure how to get an argument into an event.
protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click event. But I want to send a value to the click event (an id to be passed in an url redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to pass comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif" height="17px" width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.

Nov 18 '05 #4
Hi Louise:

You cannot change the signature of the method and the parameters it
requires, but once the event fires you can use information it provides
to dig the information out of the repeater. The sender will be the
button firing the event, and the button's Parent property represents
the row (RepeaterItem) where the button lives.

protected void btnRedirect_Click(object sender, System.EventArgs e)
{
ImageButton btn = sender as ImageButton;
RepeaterItem item = btn.Parent as RepeaterItem;

// pull info from item, ie item.Cells[0]...
}
--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 12 Nov 2004 09:39:01 -0800, louise raisbeck
<lo************@discussions.microsoft.com> wrote:
hi there, I am using c#, not quite sure how to get an argument into an event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click event.
But I want to send a value to the click event (an id to be passed in an url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif" height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.


Nov 18 '05 #5
lots of think about. thank you all.

"Scott Allen" wrote:
Hi Louise:

You cannot change the signature of the method and the parameters it
requires, but once the event fires you can use information it provides
to dig the information out of the repeater. The sender will be the
button firing the event, and the button's Parent property represents
the row (RepeaterItem) where the button lives.

protected void btnRedirect_Click(object sender, System.EventArgs e)
{
ImageButton btn = sender as ImageButton;
RepeaterItem item = btn.Parent as RepeaterItem;

// pull info from item, ie item.Cells[0]...
}
--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 12 Nov 2004 09:39:01 -0800, louise raisbeck
<lo************@discussions.microsoft.com> wrote:
hi there, I am using c#, not quite sure how to get an argument into an event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click event.
But I want to send a value to the click event (an id to be passed in an url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif" height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.


Nov 18 '05 #6
karl it worked, thanks so much

"Karl Seguin" wrote:
Try doing:

<asp:ImageButton id="btnNext" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>' .... />

then in your code.

string clientId = ((ImageButton)sender).CommandArgument;
Response.Redirect("newPage.aspx?id=" + clientId, true);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C9**********************************@microsof t.com...
hi there, I am using c#, not quite sure how to get an argument into an

event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click

event.
But I want to send a value to the click event (an id to be passed in an

url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to

pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif"

height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.


Nov 18 '05 #7
ok i'm stupid, you gave me single quotes and i used double

"louise raisbeck" wrote:
karl it worked, thanks so much

"Karl Seguin" wrote:
Try doing:

<asp:ImageButton id="btnNext" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>' .... />

then in your code.

string clientId = ((ImageButton)sender).CommandArgument;
Response.Redirect("newPage.aspx?id=" + clientId, true);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C9**********************************@microsof t.com...
hi there, I am using c#, not quite sure how to get an argument into an

event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click

event.
But I want to send a value to the click event (an id to be passed in an

url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to

pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif"

height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.


Nov 18 '05 #8
darn it. I still get 'server control is not well formed' on this.. it worked
when I sent commandargument="3" just to test, but fails when i try to include
the repeater value. any ideas?

<td style="border-bottom: #666666 1px solid" align="right"><asp:ImageButton
id="btnNext" CommandArgument="<%# DataBinder.Eval(Container.DataItem,
"ClientID") %>" onclick="btnViewClient_Click"
ImageURL="~/images/but_next.gif" height="17px" width="48px"
runat="server"/></td>
Line 364: </tr>
Line 365: </ItemTemplate>
"Karl Seguin" wrote:
Try doing:

<asp:ImageButton id="btnNext" CommandArgument='<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>' .... />

then in your code.

string clientId = ((ImageButton)sender).CommandArgument;
Response.Redirect("newPage.aspx?id=" + clientId, true);

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************@discussions.microsoft.com> wrote in
message news:C9**********************************@microsof t.com...
hi there, I am using c#, not quite sure how to get an argument into an

event.

protected void btnRedirect_Click (object sender, eventargs e) {

go to url newpage?id=[id i passed]

}
i know sender is whatever control invoked this code (e.g. button) but not
sure what the eventargs is for. I have a button which performs a click

event.
But I want to send a value to the click event (an id to be passed in an

url
redirection). How do I put this string into the argument list of the click
event?

I am also trying to put the id into the click in the html and this is
returning an error (asp server control not formed). The value I want to

pass
comes from an asprepeater. what am i missing in the following?

<asp:ImageButton id="btnNext" ImageURL="~/images/but_next.gif"

height="17px"
width="48px" onclick="btnViewClient_Click(<%#
DataBinder.Eval(Container.DataItem, "ClientID") %>)" runat="server"/>

Thank you.


Nov 18 '05 #9

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

Similar topics

4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
5
by: Lau Lei Cheong | last post by:
Hello, Let's say that I have multiple submit buttons on a form (imagebuttons actually, but documentations say that <input type=image> which a called image buttons should behave like submit...
7
by: Will | last post by:
hey guys ... quick question ... i have two buttons (cmdButton1, cmdButton2) .... how do i use the click event in cmdButton1 from cmdButton2 ? for example .. if you click cmdButton1 .. a massage...
22
by: Saul | last post by:
I have a set of radio buttons that are created dynamically, after rendered I try loop thru this set by getting the length of the set, but I keep getting an error stating the element is undefined. I...
6
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired...
2
by: =?Utf-8?B?Um9nZXIweDE=?= | last post by:
Language: c#,.net 2 This looks simple in concept: I have a page that needs to display a userid, a date/time to start vacation, a date/time to end the vacation, and two buttons: one says...
1
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function ////////////////////////////////////////////////////////////////////////////////////...
1
by: AdamGr | last post by:
Using tkinter, how does one add arguments to functions called by buttons? For example I have the line: b = Button(parent, command = self.login) but what if self.login has parameters, like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.