Click here to Skip to main content
15,908,909 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi Iam using metronic bootstrap theme. In that they used all html controls, but I want to use in my project how can I use them with asp.net controls..



Please help me out..


Thanks
Posted

Please try is as below.

IF HTML Control :
<a href=" ">Anchor</a>


Add the runat="server" and id attributes, something like:
<a runat="server" id="htmlLink" name="htmlLink" href=" ">Anchor</a>


NOTE : id and name attributes must be same.

I hope this will work. :)

Further Readings : An introduction to server-side HTML controls and HTML tags in ASP.NET applications
 
Share this answer
 
v4
Comments
Member 10324774 12-Mar-14 5:14am    
Even by giving like that also Iam not getting the functionality..
Sampath Lokuge 12-Mar-14 5:15am    
What did you mean by functionality ?
Member 10324774 12-Mar-14 5:21am    
I am using runat server for input controls and it is not validating while I click the login button.
Sampath Lokuge 12-Mar-14 6:00am    
Can you put your code snippets, which you're using ?
Member 10324774 12-Mar-14 6:10am    
<form class="login-form" action="index.html" method="post" runat="server">

Login to your account


<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>Enter any username and password.</span>
</div>
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<asp:Label CSSclass="control-label visible-ie8 visible-ie9" runat="server">Username
<div class="input-icon">

<input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="Username" name="username" runat="server"/>
</div>
</div>
<div class="form-group">
<asp:Label CSSclass="control-label visible-ie8 visible-ie9" runat="server">Password
<div class="input-icon">

<input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="Password" name="password" runat="server"/>
</div>
</div>

<div class="form-actions">
<asp:Label CSSclass="checkbox" runat="server">
<input type="checkbox" name="remember" value="1" runat="server"/> Remember me

<asp:Button runat="server" type="submit" class="btn green pull-right" Text="Login">


</div>

<div class="forget-password">

Forgot your password ?


<p>
no worries, click here
to reset your password.
</p>

</div>
<script>
login.init();</script>

login.js code is:


var Login = function () {
alert("hi");

var handleLogin = function () {

// ajax login function to be called right after the form validation success
var ajaxLogin = function(form) {
form = $(form);
$.ajax({
type: "POST",
url: "index.html",
data: form.serialize(),
dataType: "json",
beforeSend:function(){
$('.alert-danger,.alert-success').hide();
},
error: function(jqXHR, textStatus, errorThrown){
alert(errorThrown);
$('.alert-danger').show();
$('.alert-danger span').html(errorThrown);
},
success: function(data){
alert('Success!!!');
$('.alert-success').show();
$('.alert-success span').html(data);
}
});
}

$('.login-form').validate({

errorElement: 'span', //default input error message container
errorClass: 'help-block', // default input error message class
focusInvalid: false, // do not focus the last invalid input
rules: {
userid: {
required: true
},
pwd: {
required: true
},
remember: {
required: false
}
},

messages: {
username: {
required: "Username is required1."
},
password: {
required: "Password is required2."
}
},

invalidHandler: function (event, validator) { //display error alert on form submit
$('.alert-danger', $('.login-form')).show();
},

highlight: function (element) { // hightlight error inputs
$(element)
.closest('.form-group').addClass('has-error'); // set error class to the control group
},

success: function (label) {
label.closest('.form-group').removeClass('has-error');
label.remove();
},

errorPlacement: function (error, element) {
Add runat="server" and use onserverclick instead of onClick, now your html controls can act as a server side control
 
Share this answer
 
I just given id of input control same as name attribute of input control then it's working..
 
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