java script disable control problem..

Posted by Gopal_nivas under ASP.NET on 10/20/2010 | Points: 10 | Views : 1209 | Status : [Member] | Replies : 2
hi..

i have two radio buttons.

for radio button1 i have placed a file upload control. and radio button2 another textbox control is placed..

if i select radiobutton1 then textbox1 should be disabled and if i selects radio button 2 file upload1 should be disabled..

and also i want validate the enabled file upload control and enabled textbox control.(i.e to place required field validator).


give the proper script for my requirement..
this is my script..

but it works partially..

need ur suggestions..

function disablefileupload()
{
var rdb1=document.getElementById("RadioButton1");
var rdb2=document.getElementById("RadioButton2");
var fu1=document.getElementById("FileUpload1");
var fu2=document.getElementById("FileUpload2");
if(rdb1.checked==true)
{

document.getElementById("TextBox1").disabled = true;
document.getElementById("FileUpload1").disabled = false;


ValidatorEnable(document.getElementById("<%=RequiredFieldValidator1.ClientID%>"),true);
ValidatorEnable(document.getElementById("<%=RequiredFieldValidator2.ClientID%>"),false);
}
else if(rdb2.checked==true)
{
document.getElementById("FileUpload1").disabled = true;
document.getElementById("TextBox1").disabled = false;


ValidatorEnable(document.getElementById("<%=RequiredFieldValidator1.ClientID%>"),false);
ValidatorEnable(document.getElementById("<%=RequiredFieldValidator2.ClientID%>"),true);

}
}


regards
gopal.s




Responses

Posted by: T.saravanan on: 10/20/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Gopal,

Using following code
document.getElementById("TextBox1").style.display='none';


http://forums.asp.net/t/1449974.aspx

Refer this link i hope its will helpful to you.

Cheers :)

Thanks,
T.Saravanan

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Varshavmane on: 10/20/2010 [Member] Starter | Points: 25

Up
0
Down
Hello,

Did you set EnableClientScript="true" to RequiredFieldValidator?

Try doing this, hope it helps you.

Gopal_nivas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response