How to make javascript work with Ajax UpdatePanel

I am trying to add confirmation to my form. I use AJAX controls in my form fields. When I remove the Update panel and the AJAX control, my check starts, but when both things are saved, my check does not work. How can I make them work together?

<script type="text/javascript">

    function Validate() {
        var QuestionTextArea = document.getElementById("ctl00_ctl00_cphBody_midbox_fvInsert_txtQuestion");

        varError = "";
        if (!IsTextBoxEmpty(QuestionTextArea, "\nQuestion Text Area  not be Empty.")) {
            alert(varError);
            document.getElementById("ctl00_ctl00_cphBody_midbox_fvInsert_txtQuestion").focus();
            return false;
        } return true;
    }
</script>



    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>

             <asp:TextBox ID="txtQuestion" runat="server" MaxLength="1000" Columns="50" Rows="5" Style="width: 380px;
             float: none" Text='<%# Bind("Description") %>' TextMode="MultiLine" />
             <AjaxControl:TextBoxWatermarkExtender runat="server" TargetControlID="txtQuestion"
              WatermarkCssClass="water" WatermarkText="Type your Question Here.">
             </AjaxControl:TextBoxWatermarkExtender>


           </ContentTemplate>
        </asp:UpdatePanel>

When I remove the ajax extension and update panel. My text box is also checked when using UpdatePanel. The javascript function created by me is called.

0
source share
2 answers

UpdatePanel .
, , , , .

MasterPage script

<script type="text/javascript">
  Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);

  function EndRequestHandler(sender, args)
  {
    Validate(); 
  }   
</script>
+1

ajax , . ScottGu <system.web><controls><pages> web.config:

<tagMapping>
   <add tagType="System.Web.UI.WebControls.CompareValidator" 
        mappedTagType="Sample.Web.UI.Compatibility.CompareValidator, Validators, Version=1.0.0.0"/>
   <add tagType="System.Web.UI.WebControls.CustomValidator" 
        mappedTagType="Sample.Web.UI.Compatibility.CustomValidator, Validators, Version=1.0.0.0"/>
   <add tagType="System.Web.UI.WebControls.RangeValidator" 
        mappedTagType="Sample.Web.UI.Compatibility.RangeValidator, Validators, Version=1.0.0.0"/>
   <add tagType="System.Web.UI.WebControls.RegularExpressionValidator" 
        mappedTagType="Sample.Web.UI.Compatibility.RegularExpressionValidator, Validators, Version=1.0.0.0"/>
   <add tagType="System.Web.UI.WebControls.RequiredFieldValidator" 
        mappedTagType="Sample.Web.UI.Compatibility.RequiredFieldValidator, Validators, Version=1.0.0.0"/>
   <add tagType="System.Web.UI.WebControls.ValidationSummary"
        mappedTagType="Sample.Web.UI.Compatibility.ValidationSummary, Validators, Version=1.0.0.0"/>
</tagMapping>
0

All Articles