[RESOLVED]problem with timer and watermark

hi,

i have used an timer and adrotor inside update panel control in my master page of asp.net web site. in another page i have some text boxes with watermark.

my problem is that the watermarks refresh when timer tick raises.

my code for pages.aspx:

<%@ Page Language="C#"  MasterPageFile="~/MasterPageMain.master"  AutoEventWireup="true" maintainscrollpositiononpostback="true"  CodeFile="Pages.aspx.cs" Inherits="Pages" %>


<asp:Content ID="Content1" runat="Server" ContentPlaceHolderID="ContentPlaceHolderMain">
 <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server">
    </asp:ScriptManagerProxy>
     
<div class="grid" dir="rtl">
            <div class="rounded">
                <div class="top-outer">
                    <div class="top-inner">
                        <div class="top">
                            <h2 style="color:Yellow">
                                your comment</h2>
                        </div>
                    </div>
                </div>
                <div class="mid-outer">
                    <div class="mid-inner">
                        <div class="mid">
                           <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                            <table style="width: 100%">
                                <tr>
                                    <td>
                                        your Name:</td>
                                    <td style="width: 80%">
                                        <asp:TextBox ID="TextBox_Name" runat="server" CssClass="TextBox" Width="50%"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox_Name"
                                            ErrorMessage="please Inter Your Name" ValidationGroup="4546">*</asp:RequiredFieldValidator>
                                        <Ajax:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="TextBox_Name"
                                            WatermarkCssClass="WaterMark" WatermarkText="Inter Your Name">
                                        </Ajax:TextBoxWatermarkExtender>
                                    </td>
                                </tr>
                                <tr style="color: #000000">
                                    <td>
                                        EMail:</td>
                                    <td>
                                        <asp:TextBox ID="TextBox_Email" runat="server" CssClass="TextBox" Width="50%"></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox_Email"
                                            ErrorMessage="Please Enter Email Address Correctly" ValidationExpression="w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*"
                                            ValidationGroup="4546">*</asp:RegularExpressionValidator>
                                        <Ajax:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server" TargetControlID="TextBox_Email"
                                            WatermarkCssClass="WaterMark" WatermarkText="Enter Your Email Address">
                                        </Ajax:TextBoxWatermarkExtender>
                                    </td>
                                </tr>
                                <tr style="color: #000000">
                                    <td style="vertical-align: top">
                                        Your Comment:<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox_Comment"
                                            ErrorMessage="Please Enter Your Comment" ValidationGroup="4546">*</asp:RequiredFieldValidator></td>
                                    <td style="color: #000000">
                                        <asp:TextBox ID="TextBox_Comment" runat="server" CssClass="TextBox" Height="74px"
                                            TextMode="MultiLine" Width="98%"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:ValidationSummary ID="ValidationSummary1" runat="server" Style="float: right"
                                            ValidationGroup="4546" />
                                        <Ajax:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender3" runat="server" TargetControlID="TextBox_Comment"
                                            WatermarkCssClass="WaterMark" WatermarkText="Enter Your Comment">
                                        </Ajax:TextBoxWatermarkExtender>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="text-align: center">
                                        <asp:Button ID="Button_Save" runat="server" CssClass="Button" OnClick="Button_Save_Click"
                                            Text="Save" ValidationGroup="4546" /><br />
                                        <Ajax:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" ConfirmText="Are You Sure for Saving"
                                            TargetControlID="Button_Save">
                                        </Ajax:ConfirmButtonExtender>
                                        <asp:SqlDataSource ID="SqlDataSource_EnterMenuComments" runat="server" ConnectionString="<%$ ConnectionStrings:LocalSqlServer1 %>"
                                            InsertCommand="Menu_InsertComments" InsertCommandType="StoredProcedure" OnInserted="SqlDataSource_EnterMenuComments_Inserted"
                                            ProviderName="<%$ ConnectionStrings:LocalSqlServer.ProviderName %>">
                                            <InsertParameters>
                                                <asp:ControlParameter ControlID="TextBox_Name" Name="AddedBy" PropertyName="Text"
                                                    Type="String" />
                                                <asp:ControlParameter ControlID="TextBox_Email" Name="AddedByEmail" PropertyName="Text"
                                                    Type="String" />
                                                <asp:Parameter Name="AddedByIP" Type="String" />
                                                <asp:Parameter Name="MenuID" Type="Int32" />
                                                
                                                <asp:ControlParameter ControlID="TextBox_Comment" Name="Body" PropertyName="Text"
                                                    Type="String" />
                                            </InsertParameters>
                                        </asp:SqlDataSource>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="text-align: center">
                                        <asp:Label ID="Label_Message" runat="server" ForeColor="Blue"></asp:Label></td>
                                </tr>
                            </table>
                                </ContentTemplate>
                                <Triggers>
                                
                                <asp:PostBackTrigger ControlID="Button_Save"></asp:PostBackTrigger>
                                </Triggers>
                            </asp:UpdatePanel>
                            
                        </div>
                    </div>
                </div>
                <div class="bottom-outer">
                    <div class="bottom-inner">
                        <div class="bottom">
                        </div>
                    </div>
                </div>
            </div>
        </div>
   
</asp:Content>

Master Page Code:

 
<table><tr><td style="width:217px; height:200px" >
                                           <asp:Panel runat="server">
                                          <asp:UpdatePanel id="UpdatePanel1" runat="server">
                 
                                          <ContentTemplate>
                                            <asp:Timer ID="Timer1" runat="server" Interval="2000" ontick="Timer1_Tick" >
                                              </asp:Timer>
                                               <asp:AdRotator ID="AdRotator1" runat="server" Height="200px" Width="217px" BorderColor="Blue" />
                                          </ContentTemplate>
       
                  </asp:UpdatePanel>
                    </asp:Panel>
                      </td>

</tr>
</table>
<asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
        <asp:contentplaceholder id="ContentPlaceHolderMain" runat="server" >
        </asp:contentplaceholder>

and in code behind of master page in page_load and Timer Tick i use this code:

        AdRotator1.DataSource = FetchAdsFromDB();
        AdRotator1.DataBind();

please help me for solving this problem.

thanks regard

hi saeid6366 ,

From what I understand you want to handle my problem is that the watermarks refresh when timer tick raises. 

Reason:

This behavior is because Jquery watermark is client-side. 

Solution:

I would suggest you to try adding this to the page head:

<script type="text/javascript">
    function pageLoad() {

        $find('behavior')._onSubmit = function() {

        };
    }

</script>

And then add  BehaviorID ="behavior" in the TextboxWaterMark control. 

Please read the reference below for more information:

jquery WaterMark Textbox blink on postback

TextBoxWatermarkExtender blinks on postback 

I hope it helps you.

thanks very much,

I add this code above all codes in content control in pages.aspx, but face to ather problems, timer clock not raise and adrotator image not change and only first watermark is shown ( i have 3 watermarks).

why this problem occured?

hi saeid6366,

Firstly, I suggest you to check your html resource  run in debug mode or  press F12 (Debug Tool) in IE brower.

Secondly, you can try the other brower(Fix,Chrome e.g.) to run it.

Here is a demo:

http://www.webcodeexpert.com/2013/07/how-to-use-ajax-textboxwatermarkextende.html#.Ui1jgCawqM8

I hope it helps you.

As @happy… suggested

just add this code :

<script type="text/javascript">
        function pageLoad() {
            $find('bhSearch')._onSubmit = function() {

            };
        }
</script>

Where bhSearch is behaviourID of ajax watermarktextextender. And then check it out…

It solved my problem…

Leave a Reply