Reputation: 433
I have linked my html elements with ID to can read it
I can access the asp elements inside the same page in this tag
<script></script>
but I can't access its in the separate code file called"Default.aspx.cs"
also the ordinary html elements can't access its inside <script></script>
rather than the separate code file "Default.aspx.cs"
<%@ language="C#" %>
<!DOCTYPE html>
<html>
<head>
<title>A few goals</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script runat="server">
</script>
</head>
<body runat="server" onload="checkConnection">
<div class="container">
<div class="row" style="margin-top:200px;">
<center>
<div class="col-xs-12">
<h3>Authentication Step</h3>
<hr />
<form runat="server">
<input type="text" id="untxt" runat="server" placeholder="Username"/>
<input type="password" id="pwdtxt" runat="server" placeholder="Password"/>
<input type="submit" id="enterbtn" runat="server" value="Enter" />
<br />
<br />
<center><asp:Label ID="errmsg" runat="server">
</asp:Label></center>
<br />
<center><b style="color:darkred;">if account not exist , it will create a new account automaticity</b></center>
</form>
</div>
</center>
</div>
</div>
</body>
</html>
I need easy way to access these elements easily , thanks
Upvotes: 0
Views: 890
Reputation: 6613
You can't just access html tags in your .cs file, even if you add IDs to them, this is only for javascript and css. You can access the elements marked with <asp:.../>
or <asp:...></asp>
and should contain runat=server.
<asp:Button id="id" text="label" OnClick="sub" runat="server" />
This button you should be able to access throgh ID id in your Default.cs. I suggest you to take a look at this documentation.
Upvotes: 1