<<if I create a server side variable >>
Answer #1: You can't. Server-side execution knows nothing about client-side
execution and vice versa. What you can do is store the value of a variable
in the page somewhere (e.g, TextBox or HTML Hidden field) on one side or the
other, then send the page (either down to the client or back to the server),
and then retrieve the value from whereever you put it in the page.
Answer#2: Your question makes no sense: "if I create a server side variable
in my HTML how do I reference it in my code-behind ". BY definition, a
server-side variable is in your code-behind. All code-behind executes on the
server; not on the client. Code that executes in the client is "client-side
script". So, [a server-side variable in my HTML], as you are thinking, is
something that doesn't exist. Put another way, HTML is just text, not a
"variable". HTML can hold a *value* of a variable (see Answer #1 above) -
and that value would be whatever value was current for the variable at the
time it was written to the HTML. A variable is not the same thing as its
current value; so "a server side variable in my HTML" doesn't make sense.
-HTH
"aaa" <so*****@microsoft.com> wrote in message
news:eB**************@tk2msftngp13.phx.gbl...
Thanks, but again if I create a server side variable in my HTML how do I
reference it in my code-behind and vice versa?
"Bruce Barker" <br******************@safeco.com> wrote in message
news:u$**************@TK2MSFTNGP14.phx.gbl... in asp.net, functions and subs must be defined in in script blocks
(<script runat=server>), while inline code must in a <% %>
try:
<script Language=C# runat=Server>
public int myfunc()
{
int blah = 1;
if(blah != 0)
{
}
return 0;
}
</script>
<% myfunc(); %>
-- bruce (sqlwork.com)
"aaa" <so*****@microsoft.com> wrote in message
news:O3**************@TK2MSFTNGP09.phx.gbl... > I fail to see the connection between the code behind and the raw HTML
> of
> the ASPX page how do you get variables and functions to communicate
> with
> each other?
>
> I cannot get this to even fire:
> <script Language=C# runat=Server>
>
> public int myfunc()
> {
> int blah = 1;
> if(blah != 0)
> {
>
> }
> return 0;
> }
> myfunc();
>
> </script>
>
> I get the following error:
> CS1520: Class, struct, or interface method must have a return type
>
>