catching return value from javascript function in asp.net code behind
-
hi, i m having a javascript function in my aspx.cs file as // To pop up confirmation box for dissociation function confirmdissociation () { if (confirm("Are you sure to perform this action?")==true) return true; else return false; } In code behind , i have bool getresult; Button1.Attributes("script","return confirmdissociation();"); I want to store the result retured from this in a bool variable getresult (declared in code behind) Please help sandeep
-
hi, i m having a javascript function in my aspx.cs file as // To pop up confirmation box for dissociation function confirmdissociation () { if (confirm("Are you sure to perform this action?")==true) return true; else return false; } In code behind , i have bool getresult; Button1.Attributes("script","return confirmdissociation();"); I want to store the result retured from this in a bool variable getresult (declared in code behind) Please help sandeep
You can try something like this: Javascript Code: function confirmdissociation () { //alert("In Code"); if (confirm("Are you sure to perform this action?")==true) { document.getElementById("TextBox1").innerText ="true"; return true; } else { document.getElementById("TextBox1").innerText ="false"; return false; } } In Code Behind: private void Page_Load(object sender, System.EventArgs e) { Button1.Attributes.Add("onclick", "confirmdissociation();"); } --Dimple