473,503 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I get code to fire on the HTML page instead of the code behind?

aaa
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
Nov 19 '05 #1
3 1436
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

Nov 19 '05 #2
aaa
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


Nov 19 '05 #3
<<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
>
>



Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8483
by: Ken Tucker | last post by:
I've read about this issue in many articles across the net... But haven't found a solution. I see all kinds of custom code to perform sorting with datagrids, but my example is so simple, I must...
4
5527
by: Carlo Marchesoni | last post by:
I have a button that opens a new Window (some kind of search-window), which is fired using JavaScript (btnSearch.Attributes=".....";) Now I need to run some code behind code BEFORE this JavaScript...
4
2625
by: etropic | last post by:
Im confused I want an .aspx page to have a table with my data in it. At first I wrote FillTablew(); in my Page_Load even in the Code Behind file. I had it loop the db etc. and use Response.Write...
171
7584
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
17
2673
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
6
3410
by: Anders M | last post by:
I'm trying to use Inline-code to call Page_load, Page_Init or Page_PreRender methods. I've also got a code behind c#-file. I can define inline methods for buttons and so on...that works fine....
29
3645
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
7
1734
by: Alan Silver | last post by:
Hello, I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having problems....
4
3493
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7323
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6984
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1507
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.