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

javascript::

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

<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" />


CodeBehind::
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 1:40am
Updated 17-Mar-13 7:07am
ProgramFOX206.1K
v5
Comments
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.
v_k_s 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 |
Web01 | 2.8.171114.1 | Last Updated 17 Mar 2013
Copyright © CodeProject, 1999-2017
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