Click here to Skip to main content
15,905,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Based on html contlos ids Validations happen in Jquery whenver i used
or i add runtat="server" to a html contrls,jquery, Validation are stoped
what should i do
Posted
Comments
TryAndSucceed 5-Sep-13 11:21am    
Well, its obvious, jquery and javascript are used for client side actions. And when you add runat = server, controls will be looking to be resolved at Server side.
JasonMacD 5-Sep-13 11:31am    
I wish I could vote up comments, lol. Well stated my friend, well stated.

If you write runat ="server" then that html control will behave like a server side control and there Id get changed.But to get server side control in jquery ,their selector has to change.

It is a html control with runat="server" like
ex: <input type="text" id="txtname" runat="server" />

then you can get this control in jquery like
var name= $("[id$=txtname]").val()

or
var name= $('#<%=txtname.ClientID%>').val()
 
Share this answer
 
v4
Since you are adding the runat="server" to the html controls, they will be handled by the server, and thus, its id will change. Try adding clientidmode="static".

Something like this:

<input type="button" id="mybutton" value="blah!" runat="server" clientidmode="Static"/>
 
Share this answer
 
v2
XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript" language="javascript">
        $(function() {
            $('#btn1').click(function() {
                alert('test');
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input id="btn1" type="button" value="Click Me!" runat="server" />
    </div>
    </form>
</body>
</html>


I have tested this html.... It's working fine... There is no issue by adding runat=server or not...
 
Share this answer
 
Yes Its working , thank you all
 
Share this answer
 

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