Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
my Java script code in .js file is
JavaScript
function fillTextBox() {

               var dropdown = c.selectedIndex;alert("fdgdfg");
               var selvalue = c[dropdown].value;
               if(selvalue=="True")
               {
              v.value=1;
               }
               else
               v.value=0;
           }

I assigned my web controls to variables in aspx page
<script type="text/javascript" src="../../JavaScript/UserFunctions.js"></script>
JavaScript
<script type="text/javascript" language="javascript">
var c= document.getElementById('<%= ddlCompanyChit.ClientID %>');
var v=document.getElementById('<%= txtTcktNum.ClientID %>')
</script>

and am calling the function from code behind
C#
ddlCompanyChit.Attributes.Add("OnChange", "fillTextBox()");

I think the Problem is .js file could not find the web controls..so please provide the solution for how to pass web controls to .js file?
Posted
Updated 25-Nov-15 19:18pm
v2
Comments
aarif moh shaikh 26-Nov-15 1:31am    
call javascript function with parameters. pass that control id from code behind.
User-11630313 26-Nov-15 2:09am    
thanks aarif its working.....is there any other way to pass the web controls to .js file?
Arasappan 26-Nov-15 1:39am    
drag the js file and incclude in your project
User-11630313 26-Nov-15 1:43am    
i created .js file in my project
Arasappan 26-Nov-15 2:43am    
what source u used

1 solution

Check the bellow link

Click Here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900