473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image/imagebutton client validation

Hi

is there any way i can call a clientside function for validation onClick of
a Image or imagebutton?
Right now my image or imagebutton is submitting to the server, even it
return false from the clientside function.

my sample code has,
..aspx code:
-------------
function validateme()
{
if ((document.Form1.pwdOldPwd.value != "") ||
(document.Form1.pwdNewPwd.value != "") || (document.Form1.pwdRenterPwd.value
!= ""))
{
if (document.Form1.pwdOldPwd.value == "")
{
htlOldPwd.innerText = "Old Password Required";
document.Form1.pwdOldPwd.focus();
return false;
}
else
htlNewPwd.innerText = " ";
}
else
htlNewPwd.innerText = " ";

return true;
}

<input type="image" id="imgSubmit" src="images/bt_changepassword.gif"
runat="server" onServerClick = "submitme">

codebehind:
--------------
'imgSubmit.Attributes.Add("onClick", "if ( validateme() ) ")

Any ideas??

Thanks

Ganesh kolappan.


Nov 17 '05 #1
2 4941
Have you looked at client-side customvalidators?
http://msdn.microsoft.com/library/de...datorclass.asp

Karl

"ganesh kolappan" <ho********@yahoo.com> wrote in message
news:Oe**************@TK2MSFTNGP10.phx.gbl...
Hi

is there any way i can call a clientside function for validation onClick of a Image or imagebutton?
Right now my image or imagebutton is submitting to the server, even it
return false from the clientside function.

my sample code has,
.aspx code:
-------------
function validateme()
{
if ((document.Form1.pwdOldPwd.value != "") ||
(document.Form1.pwdNewPwd.value != "") || (document.Form1.pwdRenterPwd.value != ""))
{
if (document.Form1.pwdOldPwd.value == "")
{
htlOldPwd.innerText = "Old Password Required";
document.Form1.pwdOldPwd.focus();
return false;
}
else
htlNewPwd.innerText = " ";
}
else
htlNewPwd.innerText = " ";

return true;
}

<input type="image" id="imgSubmit" src="images/bt_changepassword.gif"
runat="server" onServerClick = "submitme">

codebehind:
--------------
'imgSubmit.Attributes.Add("onClick", "if ( validateme() ) ")

Any ideas??

Thanks

Ganesh kolappan.

Nov 17 '05 #2
....attribute.add("OnClick","return validateMe();")
-----Original Message-----
Hi

is there any way i can call a clientside function for validation onClick ofa Image or imagebutton?
Right now my image or imagebutton is submitting to the server, even itreturn false from the clientside function.

my sample code has,
..aspx code:
-------------
function validateme()
{
if ((document.Form1.pwdOldPwd.value != "") ||
(document.Form1.pwdNewPwd.value != "") || (document.Form1.pwdRenterPwd.value!= ""))
{
if (document.Form1.pwdOldPwd.value == "")
{
htlOldPwd.innerText = "Old Password Required";
document.Form1.pwdOldPwd.focus();
return false;
}
else
htlNewPwd.innerText = " ";
}
else
htlNewPwd.innerText = " ";

return true;
}

<input type="image" id="imgSubmit" src="images/bt_changepassword.gif"runat="server" onServerClick = "submitme">

codebehind:
--------------
'imgSubmit.Attributes.Add("onClick", "if ( validateme () ) ")
Any ideas??

Thanks

Ganesh kolappan.


.

Nov 17 '05 #3

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

Similar topics

6
22115
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick" (mouse up) change to the original image. Basically...
5
3851
by: Arthur Hsu | last post by:
Hello, I have an ImageButton that refers to an external image. How can I keep that image's aspect ratio when I set the ImageButton's size to 120x120? TIA, Arthur
3
3901
by: jens.buchta | last post by:
Hi! I'm using a DataGrid with a template column to display an Image inside of it. I'm hooking into its OnPrerender-Event to set the ImageURL-Property dynamically. Everything works just fine...
3
4393
by: Varangian | last post by:
How can I make a Image Click working before Page Load event? The Problem I'm getting is that I'm loading an ImageButton dynamically from a Web User Control. How can I make the Web User Control...
5
2618
by: Varangian | last post by:
Hi there experts, Is there a way to convert a System.Drawing.Image to an ImageButton. Maybe using ChangeType I don't know! Thank you
2
2441
by: CK | last post by:
Hello All, I am trying to extend the default asp:ImageButton to include an image for an enabled state and a second image for a disabled state. I currently did this by extending the ImageButton...
10
2370
by: Edwin Knoppert | last post by:
I have an asp.net imagebutton with a clickevent. I have enclosed an anchor around the image and a small text. If i click the image the event is executed (while the href of the anchor shows in the...
9
4404
by: tshad | last post by:
Is there a way to display images (imageButtons or linkbuttons for instance) as a max size (200px by 50px) and not have it stretch the image? What I want to be able to do is limit the real estate...
0
2050
by: Sully | last post by:
Hi Guys, I have this about 98% done and I cannot get it work properly. I have a Repeater bound to a MySQL DataSource, inside the Repeater I have an ImageButton, outside the repeater I have a...
0
7260
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
7160
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
7537
jinu1996
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...
1
7099
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
7525
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
3233
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
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
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...

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.