when i remove the update panel and script manager the javascript doesnt work .. the goal is to sending the selected calendar dates to the db which will be done in the web method, if i remove the update panel n scrpt manager the js works but with post back, i want to make the javascript work with the scriptmanger n updte panel any suggestions?
<script type="text/javascript">
$(function jScript () {
$("[id*=btnApplyLeave]").bind("click", function () {
var user = {};
user.uname = $("[id*=txtUserName]").val();
user.from = $("[id*=TextBox1]").val();
user.to = $("[id*=TextBox2]").val();
user.days = $("[id*=Label1]").val();
user.purps = $("[id*=txtPurpose]").val();
if (user.uname == '') {
alert("Enter the Username!");
return;
}
if (user.from == '') {
alert("Select a Leave Start Date from the Calendar!");
return;
}
if (user.to == '') {
alert("Select a Leave End Date from the Calendar!");
return;
}
if (user.purps == '') {
alert("Enter the reason for requesting a leave!");
return;
}
$.ajax({
type: "POST",
url: "RequestLeave.aspx/SaveUser",
data: '{user: ' + JSON.stringify(user) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert("Leave Request Sent!");
window.location.reload();
}
});
return false;
});
});
</script>
<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <contenttemplate>
from here until the closing tags of scrpt manger n update panel in between i just have asp calendars and text boxes and a submit button ('btnApplyLeave)
What I have tried:
i have tried to call the js again using
Sys.Application.add_load(jScript);
within the update panel but still didnt work