Click here to Skip to main content
13,554,631 members
Rate this:
Please Sign up or sign in to vote.
can i apply javascript on that control of that have ajax extender on it ??
because when i using javascript on textbox having watermark extender of ajax then javascript code coudnt be work ??


<script type ="text/javascript" language = "javascript" >
        function validate() {
            if (document.getElementById("<%=txtName.ClientID%>").value == "") {
                alert("please enter your name here ");
                return false;

<asp:TextBox ID="txtName" runat="server" Width="100px" ForeColor="#999999">Last Name
<asp:TextBoxWatermarkExtender ID="txtName_TextBoxWatermarkExtender" 

                                        runat="server" Enabled="True" TargetControlID="TextBox2" 

                                        WatermarkText="Last Name">
<asp:Button ID="Button1" runat="server" Text="Button" />

Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
       Button1.Attributes.Add("onclick", "return validate()")
   End Sub

here are the code which i tried but not worked...
Posted 17-Mar-13 0:40am
Updated 17-Mar-13 6:07am
Sandeep Mewara 17-Mar-13 9:40am
AFAIk, Yes. Now, you need to edit question and update with what you tried so that others can look and help with the issue.
vihangshah 17-Mar-13 11:29am
i uploaded code
sri senthil kumar 18-Mar-13 1:41am
Try this code
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return validate();" />

or if you want to bind the client event from codeBehind bind the below code you wrote in PageLoad method
Button1.Attributes.Add("onclick", "return validate()")

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04-2016 | 2.8.180515.1 | Last Updated 17 Mar 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100