I am currently using asp.net, JavaScript, and HTML Handler to create an interactive webpage.
Within a specific button's onclick event in an ASP page, I call a JavaScript function like this:
<asp:Button ID="btn_Tagging" CssClass="button" UseSubmitBehavior="false"
Text="Done" OnClientClick="DoneClick()" />
On the same page, inside a script tag, I have written the JavaScript code as shown below:
<script type="text/javascript">
function DoneClick()
{
var checkLocation = "";
var txtMM = document.getElementById("hdn_Tagging").value;///Id s of textbox assigned in code behind MB--
txtMM = txtMM.slice(0, -1);
var arrTxtMM = txtMM.split(",");
for(var j=0;j<arrTxtMM.length;j++)
{
var Loc = document.getElementById(arrTxtMM[j]).value;
if(Loc == "")
{
checkLocation = "";
break;
}
else
{
checkLocation += Loc + ":";
}
}
if(checkLocation != "")
{
var url ='Handler/newExifDetails.ashx?Id='+txtMM+'&Location='+checkLocation+'';
var completetbl, html;
$.getJSON(url,function(json)
{
$.each(json,function(i,weed)
{
var res = weed.res;
alert(res);
if(res == null)
{
}
else
{
window.top.location.href = "Dashboard.aspx";
}
});
});
}
else
{
alert("Please pick the locations for all objects");
}
}
</script>
When clicking on the button, the JavaScript alert message only appears when a breakpoint is set in Firebug or Chrome Developer Tools. Without the breakpoint, neither the alert pops up nor the redirect works as expected.