473,383 Members | 1,891 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,383 software developers and data experts.

Problem, Help

Hello
Ok, I have this datagrid an in the itemdatabound sub I have this code
strTemp = _strProgressImagesURL & e.Item.Cells(2).Text &
".jpg?e=2&w=105&h=70"
_myImage = New System.Web.UI.WebControls.Image

_myImage.ImageUrl = strTemp

_myImage.BorderStyle = BorderStyle.Inset

_myImage.BorderWidth = Unit.Pixel(5)

_myImage.ID = "img" & e.Item.Cells(0).Text

e.Item.Cells(2).Text = ""

_myImage.Attributes.Add("onclick", "GetImage()")

e.Item.Cells(2).Controls.Add(_myImage)

Now everything works fine except i cant get the attribute to work. on the
aspx file I have this just to tell me its working

<script language=vb runat=server>

sub GetImage(sender as object,e as eventargs)

response.write "Made it"

end sub

But it dont work. Help please

Thansk




Nov 18 '05 #1
2 979
Any ideas on how to deal with a control that is created on the fly to add
onclick event??

I know i can add a button to the grid, but would like to get avoid that if
possible

Thanks

"Tu-Thach" <tu*****@ongtech.com> wrote in message
news:78**********************************@microsof t.com...
Mark,

Your GetImage method is a server-side method and you are trying to add the onclick attribute on the image, which is a client-side method. That's why
it is not working.
Tu-Thach

----- Mark wrote: -----

Hello
Ok, I have this datagrid an in the itemdatabound sub I have this code strTemp = _strProgressImagesURL & e.Item.Cells(2).Text &
".jpg?e=2&w=105&h=70"
_myImage = New System.Web.UI.WebControls.Image

_myImage.ImageUrl = strTemp

_myImage.BorderStyle = BorderStyle.Inset

_myImage.BorderWidth = Unit.Pixel(5)

_myImage.ID = "img" & e.Item.Cells(0).Text

e.Item.Cells(2).Text = ""

_myImage.Attributes.Add("onclick", "GetImage()")

e.Item.Cells(2).Controls.Add(_myImage)

Now everything works fine except i cant get the attribute to work. on the aspx file I have this just to tell me its working

<script language=vb runat=server>

sub GetImage(sender as object,e as eventargs)

response.write "Made it"

end sub

But it dont work. Help please

Thansk




Nov 18 '05 #2
Mark,
Here is a sample page that adds a button dynamically and handles its click event:

public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;

private void Page_Load(object sender, System.EventArgs e)
{

HtmlInputButton button = new HtmlInputButton();
button.Value = "Generated Button";
button.ServerClick += new EventHandler(this.GeneratedButton_Click);
PlaceHolder1.Controls.Add(button);
}

public void GeneratedButton_Click(object source, EventArgs e)
{
Response.Write("DONE");
}
}
Tu-Thach
----- Mark wrote: -----

Any ideas on how to deal with a control that is created on the fly to add
onclick event??

I know i can add a button to the grid, but would like to get avoid that if
possible

Thanks

"Tu-Thach" <tu*****@ongtech.com> wrote in message
news:78**********************************@microsof t.com...
Mark,
Your GetImage method is a server-side method and you are trying to add the onclick attribute on the image, which is a client-side method. That's why
it is not working. Tu-Thach
----- Mark wrote: -----
Hello Ok, I have this datagrid an in the itemdatabound sub I have this

code strTemp = _strProgressImagesURL & e.Item.Cells(2).Text &> ".jpg?e=2&w=105&h=70"
_myImage = New System.Web.UI.WebControls.Image
_myImage.ImageUrl = strTemp
_myImage.BorderStyle = BorderStyle.Inset
_myImage.BorderWidth = Unit.Pixel(5)
_myImage.ID = "img" & e.Item.Cells(0).Text
e.Item.Cells(2).Text = ""
_myImage.Attributes.Add("onclick", "GetImage()")
e.Item.Cells(2).Controls.Add(_myImage)
Now everything works fine except i cant get the attribute to work.
on the aspx file I have this just to tell me its working
<script language=vb runat=server>>> sub GetImage(sender as object,e as eventargs)
response.write "Made it"
end sub
But it dont work. Help please
Thansk
>>>>>>>>>

Nov 18 '05 #3

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

Similar topics

11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
17
by: Jon Slaughter | last post by:
I'm having a little trouble understanding what the slicing problem is. In B.S.'s C++ PL3rdEd he says "Becayse the Employee copy functions do not know anything about Managers, only the Employee...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
11
by: ASP newbie | last post by:
I cannot run my asp.net application in w2k server. But the program works fine under w2k professional. Can anyone tell me is there any difference in the settings? Many thanks.
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.