E
Erland
Hello everyone,
I am have couple of bad concepts and would like to clear things up. As
I understand ASP.NET server controls contain runat=server tag and they
only run on the server. But I've just seen an example where javascript
can access server side controls. Now javascript is about all things
CLIENT, so how can I access server controls from my javascript, here is
one such example
<%@ Page Language="C#" AutoEventWireup="tue" CodeFile="Default.aspx.cs"
Inherits="__Default" %>
<html>
<head>
<script language="javascript" type="text/javascript">
function access()
{
document.getElementById("hidden1").value="hello"
document.getElementById("form1).submit();
}
</script>
</head>
<body>
<form id="form1" action="default.aspx" runat="server" method="post">
<asp:HiddenField Value="He" runtat="server" ID="hidden" />
</form>
</body>
</html>
--------------
Now I am confused how can I access "form and hiddenfield" in my
javascript function. I am accessing server side controls in my
javacript code? How is that possible and more importantly HOW IS THAT
HAPPENING ( What makes it possible to access server side variables from
client side code)?
Please pardon my ignorance. I know this sounds like a basic question
but I need to clear up my concepts. Any help will highly be
apprecaited.
Regards,
Erland
I am have couple of bad concepts and would like to clear things up. As
I understand ASP.NET server controls contain runat=server tag and they
only run on the server. But I've just seen an example where javascript
can access server side controls. Now javascript is about all things
CLIENT, so how can I access server controls from my javascript, here is
one such example
<%@ Page Language="C#" AutoEventWireup="tue" CodeFile="Default.aspx.cs"
Inherits="__Default" %>
<html>
<head>
<script language="javascript" type="text/javascript">
function access()
{
document.getElementById("hidden1").value="hello"
document.getElementById("form1).submit();
}
</script>
</head>
<body>
<form id="form1" action="default.aspx" runat="server" method="post">
<asp:HiddenField Value="He" runtat="server" ID="hidden" />
</form>
</body>
</html>
--------------
Now I am confused how can I access "form and hiddenfield" in my
javascript function. I am accessing server side controls in my
javacript code? How is that possible and more importantly HOW IS THAT
HAPPENING ( What makes it possible to access server side variables from
client side code)?
Please pardon my ignorance. I know this sounds like a basic question
but I need to clear up my concepts. Any help will highly be
apprecaited.
Regards,
Erland