I'm trying to call this code behind function :
protected void Insert(object sender, EventArgs e)
{
blah blah blah code
this.BindGrid();
}
While in the .aspx file I've got my java function which looks like this:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<asp:Button ID="Button2" runat="server" Text="Call Button Click" Style="display:none" OnClick="Insert" />
<asp:Button ID="btnAdd" runat="server" Text="Add" OnClientClick="return Validate();" Width="100" />
<script type="text/javascript">
function Validate()
{
var id = document.getElementById("txtStudentID").value;
Number(id);
var fn = document.getElementById("txtFirstName").value;
String(fn);
var ln = document.getElementById("txtLastName").value;
String(ln);
var cls = document.getElementById("txtClass").value;
String(cls);
var rn = document.getElementById("txtRollNumber").value;
Number(rn);
My code blah blah blah
document.getElementById("Button2").click();
PageMethods.Insert(onSuccessMethod, onFailMethod);
};
</script>
I need the Insert to work when I press the button add (the one that's visible). I'm not sure if my logic is correct or if there's a better way to it. It'd be much appreciated if someone knew hot can I call the Insert fonction from my javascript. I've tried a couple of stuff from google but none of them seem to work. thanks in advance