My datagrid has four template columns in which an ImageButton is created.
I use the following to add the OnClick event to the button.
img.Attributes.Add("OnClick", "AllButtons_Click")
The AllButtons_Click sub is:
Sub AllButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Btn As System.Web.UI.WebControls.Button = sender
Response.Write("You clicked button " & Btn.CommandArgument)
End Sub
But this sub is not run, I get an error telling me AllButtons_Click is not
defined.
Can anyone help me with this?
thanks,
Eric 5 1441
never mind....found an other way to do what I want....
thanks
"EMW" <SomeOne@MicroSoftdotCom> schreef in bericht
news:40**********************@dreader2.news.tiscal i.nl... My datagrid has four template columns in which an ImageButton is created. I use the following to add the OnClick event to the button.
img.Attributes.Add("OnClick", "AllButtons_Click")
The AllButtons_Click sub is:
Sub AllButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim Btn As System.Web.UI.WebControls.Button = sender Response.Write("You clicked button " & Btn.CommandArgument) End Sub
But this sub is not run, I get an error telling me AllButtons_Click is not defined. Can anyone help me with this?
thanks, Eric
You are trying to run a server side function on the client. Web pages don't
work that way.
You need to add a 'onlick' attribute, and have the function be a client side
function written in client side javascript.
If you want to add a server side event handler, then you have to use the
AddHandler statement - as it has nothing to do with the attributes rendered
on the client.
You just can't mix client side and server side events like this.
"EMW" <SomeOne@MicroSoftdotCom> wrote in message
news:40**********************@dreader2.news.tiscal i.nl... My datagrid has four template columns in which an ImageButton is created. I use the following to add the OnClick event to the button.
img.Attributes.Add("OnClick", "AllButtons_Click")
The AllButtons_Click sub is:
Sub AllButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim Btn As System.Web.UI.WebControls.Button = sender Response.Write("You clicked button " & Btn.CommandArgument) End Sub
But this sub is not run, I get an error telling me AllButtons_Click is not defined. Can anyone help me with this?
thanks, Eric
On Fri, 2 Jul 2004 22:01:29 +0200, "EMW" <SomeOne@MicroSoftdotCom>
wrote: My datagrid has four template columns in which an ImageButton is created. I use the following to add the OnClick event to the button.
img.Attributes.Add("OnClick", "AllButtons_Click")
The AllButtons_Click sub is:
Sub AllButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim Btn As System.Web.UI.WebControls.Button = sender Response.Write("You clicked button " & Btn.CommandArgument) End Sub
But this sub is not run, I get an error telling me AllButtons_Click is not defined. Can anyone help me with this?
thanks, Eric
Attributes.add is for adding to the html element. This has nothing to
do with the .net event model. You will have to add an event handler
to handle the click event.
-Adam
Instead of adding it as an attribute, who don't you just do
OnClick="AllButtons_Click"
Note that for an ImageButton click event you should pass
System.Web.UI.ImageClickEventArgs e instead of System.EventArgs
"EMW" <SomeOne@MicroSoftdotCom> wrote in message
news:40**********************@dreader2.news.tiscal i.nl... My datagrid has four template columns in which an ImageButton is created. I use the following to add the OnClick event to the button.
img.Attributes.Add("OnClick", "AllButtons_Click")
The AllButtons_Click sub is:
Sub AllButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim Btn As System.Web.UI.WebControls.Button = sender Response.Write("You clicked button " & Btn.CommandArgument) End Sub
But this sub is not run, I get an error telling me AllButtons_Click is not defined. Can anyone help me with this?
thanks, Eric
thanks, everybody, you replied faster then I could withdraw my question....
Eric.
"EMW" <SomeOne@MicroSoftdotCom> schreef in bericht
news:40**********************@dreader2.news.tiscal i.nl... My datagrid has four template columns in which an ImageButton is created. I use the following to add the OnClick event to the button.
img.Attributes.Add("OnClick", "AllButtons_Click")
The AllButtons_Click sub is:
Sub AllButtons_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim Btn As System.Web.UI.WebControls.Button = sender Response.Write("You clicked button " & Btn.CommandArgument) End Sub
But this sub is not run, I get an error telling me AllButtons_Click is not defined. Can anyone help me with this?
thanks, Eric
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shock |
last post by:
Hello everyone,
I am having a problem with the program below. I have isolated the problem
to the onclick event that is located throughout arrQuestions. The onclick
event refers to a function...
|
by: Andreas Knollmann |
last post by:
Hi,
I create an object like this:
var cell = document.createElement("td").
It doesn't have to be cell.
I want this cell to use the onclick event. What doesn't work in the IE as
well as with...
|
by: Jamie Jackson |
last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The
onclick event that I'm inserting works correctly in Opera, but not in
FF or IE.
I'm retroactively adding the statement...
|
by: RobG |
last post by:
I am trying to dynamically add an onclick to an element,
however I just can't get the syntax right. consider the
following function:
function doClick (evt,x) {
// do things with evt and x
}
...
|
by: abs |
last post by:
Hi all.
Is that possible to call the onclick, onchange or other event from JS ? I
mean how to make the browser think that user clicked the element (onclick
event) ? Eg. I have <element...
|
by: Stuart Shay |
last post by:
Hello All
I am working on ASP.NET 1.1 Custom Pager that allows a User to Enter a
Number in a TextBox and go to the page selected.
Since the OnClick Event does not work in ASP.NET 1.1 for a...
|
by: Carlos Araya |
last post by:
I have the following link on a web page
<p class="menuitem"><a href="#"
onclick="loadFragment('http://rivendellweb.net/fortress/home',
'index')" title="The Fortress Home">The Fortress...
|
by: =?Utf-8?B?Uml0YUc=?= |
last post by:
I posted this question in the C# discussion group but am posting it here
also since ASP is involved.
I'm new to C# and need some help regarding an onClick event not firing.
I have a data grid...
|
by: sourcie |
last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz"
I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
|
by: yawnmoth |
last post by:
http://www.frostjedi.com/terra/scripts/demo/this-alert.html
http://www.frostjedi.com/terra/scripts/demo/this-alert2.html
Why, when you click in the black box, do the alert boxes say different...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
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...
|
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...
| |