Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
protected void Page_Load(object sender, EventArgs e)
       {

           Button1.Attributes.Add("onclick","javascript:prompt('Enter Checkbox name.')");
       }

       protected void Button1_Click(object sender, EventArgs e)
       {
           String s="Viv";
           Response.Write(s);
           s ="<script language="'javascript'">return prompt('Enter Checkbox name.','name') </script>";
           Response.Write(s);

       }


Not getting value in s variable. suggestion?
Posted
Comments
[no name] 16-Aug-12 9:18am    
What do you mean that you are not getting a value in s? Does s not contain the string "Viv" and "<script language="'javascript'">return prompt('Enter Checkbox name.','name') </script>"?
bbirajdar 16-Aug-12 9:27am    
Right.. It should contain the string as told by you... BTW, I was able to read the mind of OP :) and he is expecting the 's' variable to have the value returned by the javascript 'prompt' function...
StianSandberg 16-Aug-12 9:32am    
run your site, right-click your browser window and select "view source". Then you will see that this approach (response.write) is no good..

If you are a web developer, you should know that the javascript is executed on client browser and the C# code is executed on server.

You need to assign the value returned from the javascript 'prompt' function to a hidden variable and then read the value of the hidden variable on a server event.
 
Share this answer
 
var no =prompt('Enter No of checkBox You want to Enter','Value');

In javascript and i m setting hiddenfiled to value of that input and its working nicely.
 
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