473,602 Members | 2,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable from code behind into ASP page.

Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?

Thanks!

--
Only the Best Freeware at http://www.vbmark.com
Jul 1 '07 #1
9 1408
On Jul 1, 7:37 am, vbMark <n...@email.com wrote:
Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?

Thanks!

--
Only the Best Freeware athttp://www.vbmark.com
HI...

<%# MyVar %>
this. is databinding ...
but for this you got to call page.databind()

Thanks
Masudur
www.kaz.com.bd
http://munnacs.110mb.com

Jul 1 '07 #2
<% MyVar %only evaluates MyVar and doesn't return anything.

<%= MyVar %returns MyVar value.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"vbMark" <no@email.comwr ote in message
news:Xn******** ************@19 9.45.49.11...
Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?

Thanks!

--
Only the Best Freeware at http://www.vbmark.com

Jul 1 '07 #3
"vbMark" <no@email.comwr ote in message
news:Xn******** ************@19 9.45.49.11...
Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?
<% = MyVar %>

The equals sign is shorthand for Response.Write
--
http://www.markrae.net

Jul 1 '07 #4
Also I think the variable need to be marked as internal or protected to be
able to be accesed from the aspx source

HTH

Siva

"Mark Rae" wrote:
"vbMark" <no@email.comwr ote in message
news:Xn******** ************@19 9.45.49.11...
Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?

<% = MyVar %>

The equals sign is shorthand for Response.Write
--
http://www.markrae.net

Jul 1 '07 #5
"Sivakumar G" <Si********@dis cussions.micros oft.comwrote in message
news:C4******** *************** ***********@mic rosoft.com...
Also I think the variable need to be marked as internal or protected to be
able to be accesed from the aspx source
protected or public - internal won't be visible...
--
http://www.markrae.net

Jul 1 '07 #6
Hi Mark,

As other members have mentioned, for ASP.NET, the classic ASP like inline
express such as <%= variable or function %still work, you can use it to
display value in aspx template based on some page's member variable(or
helper function) in codebehind. Also, you need to make sure that the
variable or function is non-private (protected or public ) so that they can
be referenced in aspx template.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 2 '07 #7
Mark,

Internal works for me as protected/public. FYI I tested using ASP .net 2.0.
Here the point is that what Steven suggested. A non private variable will do
the job.

cheers

Siva

"Mark Rae" wrote:
"Sivakumar G" <Si********@dis cussions.micros oft.comwrote in message
news:C4******** *************** ***********@mic rosoft.com...
Also I think the variable need to be marked as internal or protected to be
able to be accesed from the aspx source

protected or public - internal won't be visible...
--
http://www.markrae.net

Jul 2 '07 #8
"Steven Cheng[MSFT]" <st*****@online .microsoft.comw rote in message
news:Y2******** ******@TK2MSFTN GHUB02.phx.gbl. ..
As other members have mentioned, for ASP.NET, the classic ASP like inline
express such as <%= variable or function %still work, you can use it to
display value in aspx template based on some page's member variable(or
helper function) in codebehind. Also, you need to make sure that the
variable or function is non-private (protected or public ) so that they
can
be referenced in aspx template.
Er, yes I know, as per my earlier post (the one you appear to be replying
to)...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jul 2 '07 #9
Thanks for your reply Mark,

Oh, I originally reply to the OP "vbMark", just haven't noticed that there
are more than one Mark here :-). Sure, appreciate your informative input
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 2 '07 #10

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

Similar topics

2
6160
by: lsf_80 | last post by:
I am using ASP.net and C# as code behind. I wrote one function in the "page load" (code behind) and how can i call back the variable in the aspx page? Thank you. if i put response.write, error message prompted: "WebService1.WebForm10.aa' is inaccessible due to its protection level"
1
1949
by: Andrew Pasetti | last post by:
I'm having trouble binding/displaying a class variable to the display aspx page. Perhaps someone can suggest what I am doing wrong. ################################### Within the .aspx page I have this: ################################### <td><%# p.ParcelName %></td> #############################################
4
3504
by: Bob T | last post by:
Hi All, I am trying to pass a variable from my VB asp.net script (from for example Sub Page_Load in mypage.aspx.vb) to my Client side script. I have found and looked at a very good example "Client and Server Scripting in Web Pages" but it only shows server side scripting that is written in HTML in mypage.aspx and not script from mypage.aspx.vb. How can I pass a variable value from mypage.aspx.vp to my client side script?
3
807
by: Wayne Wengert | last post by:
I have an application where a session variable is set in an ASPX page, The process calls an ASP page and when in that page the session variable appears to be null. How can I pass a session variable to an ASP page? Wayne
3
2536
by: Ryan Taylor | last post by:
Hi. I need to be able to access a public code behind variable within my ASPX page. The reason is that I have a user control "Header" which defines a table layout, and is included in all my pages, at various levels in the website heirarchy. The table requires a background image. My images folders is at the root of the website, effectively "~/images/". I need the background image to show whether I at a page in the root of my website or in...
12
2921
by: Phil Certain | last post by:
Hi, I'm trying to do something very simple...or at least it should be. I have created a host page (gen.aspx) and a very simple user control (us.ascx). The corresponding code-behind files are gen.aspx.vb and uc.ascx.vb. With simple html or self contained vb in the user control, everything is fine and dandy. So the next stage is to pass back a simple variable from the user control to the host page. I used VS.NEt to create the files.
5
3521
by: Paul | last post by:
Just wondering if someone could provide an example of passing a variable from the code behind to javascript in vb. I want to have one control have focus with the page loading with one condition and have another control with focus after the page loads from a different condition. A gets set in the code aspx.vb file and the script might look something like, <script language="javascript"> function DoHighlight(a) { if a = 1 {...
3
3931
by: Pierre | last post by:
Hello, In an aspx page (mypage.aspx) from a web projet, I would like to get the value of a variable of the projet that is declared as public in a module. The variable can be called from anywhere in the code behind page and in the class files, but when I try to call it from an aspx page, it raises an error. <%=myvar%> in mypage.aspx raise an error : the name "myvar" is not declared.
4
2652
by: simon | last post by:
hello. relatively new to vb.net, i'm using VS 2003 and .net 2.0 i have a web app that i'm i have a user control that displays a simple 1 row table as the header of the page. the user control takes one input variable, the string that will be displayed as the title of the page. example call: <uc1:Header runat=server ID="ucHeader" Title="Home Page" /> what i am looking to do on a certain page is have the "title" value be dynamic, in...
1
9879
by: supin | last post by:
hi, i work in asp.net2.0/c#.not much expert in javascript.i have a variable declared in the c# code behind page.assume the variable contains some value. i have a javascript function in the <script> </script> area of the html source view of the corresponding aspx(asp.net)page. my requirement is how do i access the variable which i mentioned above in the c# code behind page?i need to use the variable in the javascript function. ...
0
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1254
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.