vendredi 19 septembre 2014

AJAX with CommandArgument not


Vote count:

0




I'm trying to create a popup using this code script:



function lookupDetalhes()
{
$.ajax({
type: "POST",
url: "detalhesOrc.aspx",
data: { tempOrcID: $("#detalhesImageButton").val() }
}).done(function (msg)
{
alert("Detalhes: " + msg);
});
}


This HTML that binds perfectly with the code:



<input type="image" id="detalhesImageButton" src="images/Detalhes.png" onclick="lookupDetalhes()" value='<%# Eval("tempOrcID") %>' />


And this .aspx page that retrieves data from the database. It works, but doesn't show the alert. Instead, it shows the HTML page itself...


File: detalhesOrc.aspx



<html xmlns="http://ift.tt/lH0Osb">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="detalhesRetorno" Font-Names="Verdana" Font-Size="small" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>


File: detalhesOrc.aspx.cs



protected void Page_Load(object sender, EventArgs e)
{
try
{
Int32 tempID;
String temp = Convert.ToString(e); // this doesn't work because it's System.EventArgs
if (!Int32.TryParse(temp, out tempID)) // this returns FALSE, of course
return; // then, on return, the HTML code of detalhesOrc.aspx is shown
using (var context = new DBORCEntities())
{
// It doesn't even reach here...
// database procedure
detalhesRetorno.Text = context.Get_Detalhes(tempID).ToString();
}
}
catch (Exception ex)
{
throw new Exception("Error!", ex);
}
finally
{
}
}


I've tried using with CommandArgument and OnCommand that worked, calling the procedure, BUT I don't know how to show the alert or popup.


Any help?


Regards.



asked 5 mins ago







AJAX with CommandArgument not

Aucun commentaire:

Enregistrer un commentaire