Click here to Skip to main content
15,565,950 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,

I want to call my javascript function from my button inside update panel
I have written above code but its not calling that function, as it is inside update panel.

C#
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
   <ContentTemplate>
     <fieldset>
          <asp:Button ID="btnSubmit" runat="server" CssClass="btn"  OnClientClick ="return validate()" onclick="btnSubmit_Click" Text="Submit" Width="109px"/>
           <br />
       <asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#FF3300">                      </asp:Label>
          </fieldset>
       </ContentTemplate>
</asp:UpdatePanel>


Javascript Function

<script language="javascript" type="text/javascript">
function validate() {
var summary = "";
summary += isvalidProposerName();
summary += isvalidProposlAmount();
summary += isvalidDocRcvdDate();
summary += isvalidDocRcvdTime();
summary += isvalidIntermediaryCode();
if (summary != "") {
alert(summary);
return false;
}
else {
return true;
}

}
function isvalidProposerName() {
var uid;
var temp = document.getElementById("txtProposerName").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Proposer Name" + "\n");
}
else {
return "";
}
}
function isvalidProposlAmount() {
var uid;
var temp =document.getElementById("txtProposalAmount").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Proposal Amount" + "\n");
}
else {
return "";
}
}
function isvalidDocRcvdDate() {
var uid;
var temp =document.getElementById("txtDocRcvdDate").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Doc Rcvd Date" + "\n");
}
else {
return "";
}
}
function isvalidDocRcvdTime() {
var uid;
var temp =document.getElementById("txtDocRcvdTime").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Doc Rcvd Time" + "\n");
}
else {
return "";
}
}
function isvalidIntermediaryCode() {
var uid;
var temp =document.getElementById("txtIntermediaryCode").value;
uid = temp.value;
if (uid == "") {
return ("Please Enter Intermediary Code" + "\n");
}
else {
return "";
}
}
</script>
Posted
Updated 14-May-13 21:15pm
v2

XML
Hi Sunil,

it looks like your javascript functions have issues, not with update panel.
debug your javascript functions, run your page and see if you get any javascript error in left bottom of browser.


one issue i noticed is:
var temp = document.getElementById("txtProposerName").value;
uid = temp.value;

in above code you are alredy taking value of textbox,but in second line again you are trying to get value. this might throw an error.
rest do your own debugging
 
Share this answer
 
Thanks yaar, you are right...
One more silly mistake by me... :)
Thank you so much.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900