473,511 Members | 10,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retriving data from some asp.net object to client side javascript

Hello. :)
I'm relatively new in web programing...

Anyway...

How can I, for example, retrive data from Profile object (or what so
ever) to some variable declared in javascript tag on client side?

For example, let's say I have this code in Some_Page.aspx:

....
Profile.Name = "Some Name";
....

And I have some variable in java script tag:

var someVariable;

How can I get this "Some Name" from Profile.Name to someVariable?

Tnx. :)

Mar 9 '07 #1
4 1246

<script>
var someVariable = <asp:Literal runat="server" id="ltlAux"
EnableViewState="false" Text='<%# Profile.Name %>' />;
</script>

And then in code behind you may call ltlAux.DataBind() if it is not
already being called by some parent in hierarchy.

If dynamic databinding is not appropriate for your app, you may
explicity assign as ltlAux.Text = Profile.Name in code-behind

Mar 10 '07 #2
<script>
var someVariable = "<asp:Literal runat="server" id="ltlAux"
EnableViewState="false" Text='<%# Profile.Name %>' />";
</script>

And then in code behind you may call ltlAux.DataBind() if it is not
already being called by some parent in hierarchy.

If dynamic databinding is not appropriate for your app, you may
explicity assign as ltlAux.Text = Profile.Name in code-behind

Mar 10 '07 #3
On Mar 9, 10:50 pm, "Ivan S" <ivan.sku...@gmail.comwrote:
Hello. :)
I'm relatively new in web programing...

Anyway...

How can I, for example, retrive data from Profile object (or what so
ever) to some variable declared in javascript tag on client side?

For example, let's say I have this code in Some_Page.aspx:

...
Profile.Name = "Some Name";
...

And I have some variable in java script tag:

var someVariable;

How can I get this "Some Name" from Profile.Name to someVariable?

Tnx. :)
You can assign the Profile.Name to a public variable, say

public string profileName;
.....

profileName = Profile.Name;

and use it as

<script>
var someVariable = '<%=profileName%>';
</script>

Mar 10 '07 #4
Thank you very much, it works. :)

Muhammad Naveed Yaseen je napisao/la:
<script>
var someVariable = "<asp:Literal runat="server" id="ltlAux"
EnableViewState="false" Text='<%# Profile.Name %>' />";
</script>

And then in code behind you may call ltlAux.DataBind() if it is not
already being called by some parent in hierarchy.

If dynamic databinding is not appropriate for your app, you may
explicity assign as ltlAux.Text = Profile.Name in code-behind
Mar 10 '07 #5

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

Similar topics

2
1674
by: Pavils Jurjans | last post by:
Hello, I have a fairly complex project with server-side written in C# (.NET), and client-side heavily relying on the presence on JavaScript-compatible scripting engine. One of the features thie...
3
45941
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem...
12
6521
by: Russ | last post by:
I'm interested in setting up a web page where live data can be displayed in real-time on the web page. For example: I would like to display a (nice looking) graph of some data value versus time...
1
2668
by: Jim Hammond | last post by:
I can get data from a client-side assembly to the server in two manual steps, but I need to be able to do it in one step. Step 1: The user presses the manually coded "Step 1" button, which calls...
2
12535
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
20
6808
by: Luke Matuszewski | last post by:
Welcome As suggested i looked into JSON project and was amazed but... What about cyclical data structures - anybody was faced it in some project ? Is there any satisactional recomendation... ...
0
12055
by: sonu | last post by:
I have following client side code which i have used in my asp.net project SummaryFeatured Resources from the IBM Business Values Solution Center WHITEPAPER : CRM Done Right Improve the...
17
3502
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
2
3065
by: balakrishnan.dinesh | last post by:
Hi frnds, Im having a problem with retriving "\" backslash , In my javascript client side page , ill get the response from the server side , the response will contain some url like...
1
1095
by: Ivan S | last post by:
Hello. :) I'm relatively new in web programing... Anyway... How can I, for example, retrive data from Profile object (or what so ever) to some variable declared in javascript tag on client...
0
7148
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...
0
7367
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
7430
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
7089
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
7517
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
5673
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,...
0
3230
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
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.