Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "if(confirm('Show in Home Page?')==true)
{document.getElementById('" + hdnvalue.ClientID.ToString() + "').Value='true'}
else{document.getElementById('" + hdnvalue.ClientID.ToString() + "').Value='false'}{document.getElementById('" + btnSavechecked.ClientID + "').click()}", true);
Posted
Updated 30-Sep-14 0:11am
v3
Comments
ChintanShukla 30-Sep-14 4:53am    
Can you pls be a bit clear.
ghanem90 30-Sep-14 5:01am    
no value save in hdnvalue why??
please whats problem
ghanem90 30-Sep-14 5:25am    
pls can you hlep me??

Hi,

You should create java script function in js file or in script tag, and after that call it from code behind like:

JavaScript
<script type="javascript">
function test(){
      // your java script function code here
}
</script>

Then call test() function from code behind,
C#
ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "test()", true);
 
Share this answer
 
Comments
ghanem90 30-Sep-14 5:33am    
thank you but i needed in code behind
JR009 30-Sep-14 5:52am    
if you want to access the server side control in js function, then you can also do this in aspx page in script tag.
ghanem90 30-Sep-14 5:56am    
i wrote in code behind because i have check in more thing and run the script
JR009 30-Sep-14 6:03am    
Ok, then there may be some wrong code in javascript function. can u provide your javascript code?
ghanem90 30-Sep-14 6:12am    
in my question that all my javascript code
Try this!

JavaScript
document.GetElementById("<%=hdnvalue.ClientID %>").value = "true";


Value attribute in small case JavaScript is Case sensitive also make a seperate function as given in Answered by RJ009 above
 
Share this answer
 
Comments
ghanem90 30-Sep-14 5:40am    
not work error on ""
ChintanShukla 30-Sep-14 5:44am    
Did you wrote function as provided in Solution 1?
ghanem90 30-Sep-14 5:54am    
i write my function in code behind not in aspx page

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