473,473 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Declare variable in Codebehind and display it in the HTML form

ak1dnar
1,584 Recognized Expert Top Contributor
Hi there,

In classic asp(using vb) I can declare variables like this.

Expand|Select|Wrap|Line Numbers
  1.  <% 
  2. Dim var1 as string ="My Var Value"
  3. %>
  4.  
And Some Where in my asp page I can print it.Like this,
Expand|Select|Wrap|Line Numbers
  1. <%=var1%>
Correct ?

How can I do the same thing in ASP.NET(1.1).What i need really I need to Declare the var1 at the codbehind and need to print it in a HTML Form element

Thanks!
Jul 6 '07 #1
4 1697
jhardman
3,406 Recognized Expert Specialist
Hi there,

In classic asp(using vb) I can declare variables like this.

Expand|Select|Wrap|Line Numbers
  1.  <% 
  2. Dim var1 as string ="My Var Value"
  3. %>
  4.  
And Some Where in my asp page I can print it.Like this,
Expand|Select|Wrap|Line Numbers
  1. <%=var1%>
Correct ?

How can I do the same thing in ASP.NET(1.1).What i need really I need to Declare the var1 at the codbehind and need to print it in a HTML Form element

Thanks!
moved to .NET forum

Jared
Jul 12 '07 #2
Plater
7,872 Recognized Expert Expert
I am fairly certain those types of constructs are still valid.
If you declared a variable in the code behind section called: MyInt

Then in your aspx page you could put like:
Expand|Select|Wrap|Line Numbers
  1. MyInt has the value of <%=MyInt.ToString() %>
  2.  
Jul 12 '07 #3
Frinavale
9,735 Recognized Expert Moderator Expert
I am fairly certain those types of constructs are still valid.
If you declared a variable in the code behind section called: MyInt

Then in your aspx page you could put like:
Expand|Select|Wrap|Line Numbers
  1. MyInt has the value of <%=MyInt.ToString() %>
  2.  
Plater is right, this will work perfectly fine :)

You have to make sure that you declare your variable as a Public Integer though or else it will not be accessible.

-Frinny
Jul 13 '07 #4
ak1dnar
1,584 Recognized Expert Top Contributor
Thank you Plater.
Thank you Frinavale.

It really helped to me.
-Ajaxrand
Jul 16 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Krunom Ancini | last post by:
Hi, im just the beginner and im using c#-codebehind in my asp.net-application.... What should i do to make my application work "without" code-behind (without dll.-s in bin-folder)? I was...
6
by: rick | last post by:
Noob problem. I prefer to keep all my scripts in an external '.js' file. I am currently loading the external '.js' file from the header. Problem is I would like to declare a global variable in the...
4
by: Boban Dragojlovic | last post by:
I create a new webform (I always use codebehind), and I insert some server-side controls into the form (the ASPX) Later, I switch to codeview, and I notice that some (sometimes all) of the...
5
by: Gary Vidal | last post by:
I have a client side Javascript which checks an OrderQuantityField against a hidden Textbox of the Minimum Order Quantity. I dont want to do validation on a postback. I would like to be able to...
13
by: Benjamin Smith | last post by:
I am controlling the display status of a table row using the following code. <TR id="CCRow" style="DISPLAY:none"> Instead of hard coding "none" above, I would like to change that value using a...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
1
by: Randall Parker | last post by:
Using VS 2003 and Cassini web server. I'm new to ASP.Net and so this may be a dumb question. I'm getting an error where the type 'FarmLand.WebForm1' is not found. The Codebehind C# source file...
2
by: assgar | last post by:
I am having problems getting the user selected form info to inserted into the mysql database. I am also rec eving an error: Warning: Variable passed to each() is not an array or object in ...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
0
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
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
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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.