java script in asp.net..

Posted by Gopal_nivas under ASP.NET on 10/18/2010 | Points: 10 | Views : 2036 | Status : [Member] | Replies : 4
hi..

i have two radio buttons.

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

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

how to do this in java script.

need ur suggestions with examples..

regards
gopal.s




Responses

Posted by: Abhi2434 on: 10/18/2010 [Member] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Use

var rad1 = document.getElementById('radiobutton1");

if(rad1)
{
if(rad1.checked)
{
var fupload2 = document.getElementById("fileupload2");
fupload2.disabled = true;
}
else
{
var fupload1 = document.getElementById("fileupload1");
fupload1.disabled = true;
}
}

I hope this would help you.



www.abhisheksur.com

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

Posted by: Gopal_nivas on: 10/18/2010 [Member] Starter | Points: 25

Up
0
Down
hi abi,

during page load itself i want enable the file upload control and disable file upload 2..


how to do this

regards
gopal.s



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

Posted by: Raja on: 10/18/2010 [Member] Starter | Points: 25

Up
0
Down
Hi Gopal_nivas,

By the time, I was preparing your solution, I saw Abhi2434 has already given you a solution. However if that solution doesn't work, try below code snippet. Simply copy-paste into aspx or html page to see how it is working.

<html>

<head>File upload</heaD>
<body>
<form runat="ServeR">
<p>
<input type="radio" id="radio1" name="radio1" onclick="Select('<%= FileUpload1.ClientID %>', '<%=

FileUpload2.ClientID %>')" />
<asp:FileUpload Id="FileUpload1" runat="Server"/>
</p>

<p>
<input type="radio" id="radio1" name="radio1" onclick="Select('<%= FileUpload2.ClientID %>', '<%=

FileUpload1.ClientID %>')" />
<asp:FileUpload Id="FileUpload2" runat="Server"/>
</p>

</form>

<script>
function Select(id, id1)
{
document.getElementById(id).style.display = '';
document.getElementById(id1).style.display = 'none';
}
</script>

</body>
</html>


Thank you

Regards,
Raja, USA

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

Posted by: Raja on: 10/18/2010 [Member] Starter | Points: 25

Up
0
Down
If you want to enable in the Page load itself, why not you write something like below in the Page_Load event.

FileUpload2.Enabled = false;

Regards,
Raja, USA

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

Login to post response