Click here to Skip to main content
15,887,821 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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::

XML
<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
<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::
VB
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
Updated 17-Mar-13 6:07am
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.
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)



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