When option is selected from dropdown for eg:
i have one dropdown in which two listitem " yes & no"
if yes is selected then fileupload control shown otherwise hide
pn.Own_Land = Convert.ToInt32(ddl.SelectedValue);

Sachin SinghRank #66 · 26.2K reputationPosted Mar 17, 2023, 3:00 PM EDT
use this
$(document).ready(function () { $('[id*=FileUpLoad1]').show(); $('[id*=ddlownlandancestral]').change(function () { if ($(this).val() == "1") { $('[id*=FileUpLoad1]').show(); } else { $('[id*=FileUpLoad1]').hide(); } }); });Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 17, 2023, 6:59 AM EDT
Hello Garima,
You can achieve this functionality using jQuery. Here is an example:
First, give an ID to your fileupload control, like this:
Then, add a script tag in your ASPX page and write the following jQuery code inside it:
$(document).ready(function () { $("#").change(function () { if ($(this).val() == "01") { $("#fileUploadControl").show(); } else { $("#fileUploadControl").hide(); } }); });Thanks
Naimis Makwana
Garima BansalRank #1,555 · 1K reputationPosted Mar 17, 2023, 7:21 AM EDT
Naimish Makwana
I am trying this way but Not working
Yes No $(document).ready(function () { $("#").change(function () { if ($(this).val() == "1") { $("#FileUpLoad1").show(); } else { $("#FileUpLoad1").hide(); } }); });Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 17, 2023, 7:33 AM EDT
Make sure you have included the jQuery library in your ASPX page before your script tag. You can include it by adding the following code in your head section:
Garima BansalRank #1,555 · 1K reputationPosted Mar 17, 2023, 7:46 AM EDT
Naimish Makwana
Already added jquery library but still not works
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 17, 2023, 7:56 AM EDT
Can you inspect the HTML source code of your page in the browser and look for the actual IDs of the FileUpload control.Then, you can update your jQuery code to use the actual IDs instead of the client IDs.
Thanks
Tuhin PaulRank #7 · 71.9K reputationPosted Mar 18, 2023, 9:06 AM EDT
script with some improvements:
$(document).ready(function () { const fileUpload = $('[id*=FileUpLoad1]'); const ddlAncestral = $('[id*=ddlownlandancestral]'); fileUpload.show(); ddlAncestral.change(function () { if ($(this).val() == "1") { fileUpload.show(); } else { fileUpload.hide(); } }); });