<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
function chvisible(controlId)
{
var control = document.getElementById(controlId);
if(control.style.display == "none" || control.style.display == "")
control.style.display = "block";
control.body.text="";
else
control.style.display = "none";
}
when i change the to CheckBox
what i will write instead of "chvisible('<%=TextBox1.ClientID %>');"
in onCheckedChanged Event ?????
checkbox serverside control doesnt hava onclick event
when i try to write this following , it dont run
Raja KrishnamurthyPosted Mar 8, 2011, 7:31 AM
Please try this:
On pageload
Checkbox1.Attributes.Add("onclick","chvisible('"+TextBox1.ClientID+"');");
The error you are getting is because the ClientID might not have rendered. And you can remove the onCheckedChanged which you have given in the Checkbox tag. Also don't forget to check for postback.
HTH
Happy Programming!!!
Regards,
Raja
BassemPosted Mar 8, 2011, 8:13 AM
BassemPosted Mar 8, 2011, 8:07 AM
Raja KrishnamurthyPosted Mar 8, 2011, 8:06 AM
HTH.
Happy Programming!!!
Regards,
Raja
Raja KrishnamurthyPosted Mar 8, 2011, 7:59 AM
What do you mean by How do I make textbox as null?
Do you want to remove from the DOM? I think your code of making it visible / invisible and setting the text as "" is fine.
HTH.
Happy Programming!!!
Regards,
Raja
BassemPosted Mar 8, 2011, 7:58 AM
i do as u said
but unfortunately not work .
BassemPosted Mar 8, 2011, 7:54 AM
it works correctly :D :D Thank you .
what if i have 20 textbox and checkbox Am i use the same way to do that ??
what about this question :) ?
how i make textbox null when user check on it (javascript code)
thank you man :)
Raja KrishnamurthyPosted Mar 8, 2011, 7:50 AM
I think you mean to make the text in the textbox as "" and not making the textbox as null.
Add this to your JS
control.value="";
HTH.
Happy Programming!!!
Regards,
Raja
BassemPosted Mar 8, 2011, 7:47 AM
try it with yourself it will not work
thank your for helping me :)
when i use
Checkbox1.Attributes.Add("onclick","chvisible('"+TextBox1.ClientID+"');");
it work perfectly
about text displayed in text box
and about this crazy line which make you angry control.body.text=""; :D :D (^_^)
how i make textbox null when user check on it (javascript code)
thanx Manikavelu , u are good helper
Manikavelu VelayuthamPosted Mar 8, 2011, 7:30 AM
BassemPosted Mar 8, 2011, 7:23 AM
error in the line of checkbox :
Manikavelu VelayuthamPosted Mar 8, 2011, 7:11 AM
2. if(control.style.display == "none" || control.style.display == "")
{
Include the content of true condition with braces.
3. OnCheckedChanged="chvisible('TextBox1.ClientID');"
Put it like above .
If the above changes done, your code will work fine
BassemPosted Mar 8, 2011, 6:55 AM
but it also not success when i write
Manikavelu VelayuthamPosted Mar 8, 2011, 6:46 AM
You can use the same OnClick event like in Html control for client side event.