How to store in a web page dynamic data in a web Page ?

Hi,

I have 1 ListBox containing :
1 ~ MACHINE A ~ 0 ~ 23 ~ R
2 ~ MACHINE B ~ 4 ~ 477 ~ R
3 ~ MACHINE C ~ 2 ~ 78~ R
4 ~ MACHINE D ~ 9 ~ 76~ T

I should have :
1 ~ MACHINE A
2 ~ MACHINE B
3 ~ MACHINE C
4 ~ MACHINE D

This ListBox is populated by a DataBase
=> So the line numbers isn't known for advance.

How to store in ASP.NET these values (0, 23, 4, ...) ? I need these values into the web page because I need them for JavaScrip functions.
Do List like HiddenFields exist ?

Thanks for your tips.

David.
0
david4444
6/26/2008 4:57:57 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

9 Replies
1050 Views

Similar Articles

[PageSpeed] 33

i am bit confused by your question.. can you explain it once more


"Mark as answered if you feel this helps you"
"Curiosity is Bliss"
Regards,

Ravi Kant Srivastava
(Sr. Software Engineer)
Connexxions Business
Mumbai
INDIA
0
blurearc
6/26/2008 5:23:45 PM

 Well I try to hide data. The 1st ListBox you see has the data (0, 23, ...) I need for my JavaScript functions. But the user must not see these data. So I must keep the data (0, 23, ...) for my JavaScript, but It mustn't be visible.

Actual ListBox (which provides everything needed for my JavaScripts functions) :
1 ~ MACHINE A ~ 0 ~ 23 ~ R
2 ~ MACHINE B ~ 4 ~ 477 ~ R
3 ~ MACHINE C ~ 2 ~ 78~ R
4 ~ MACHINE D ~ 9 ~ 76~ T

Target ListBox (without the data needed for my JavaScript functions) :
1 ~ MACHINE A
2 ~ MACHINE B
3 ~ MACHINE C
4 ~ MACHINE D

The problem is I can't use HiddenFields because 1 information equals 1 HiddenField. And I don't know how much data I'll have to store in the page.

 So, do you know a means to keep hidden data which is like the ListBox object, but Hidden ?

Thanks.

 

 


David.
0
david4444
6/26/2008 5:49:14 PM

are you binding the row straight from a datasource object or a custom generic data collection.  If you are getting straight from the DB, then my create a buisiness logic class and and a generic list like:

public class MyObject{

private string _name;

private int _attr1;

private int _attr2;

private string _attr3;

public string Name{

get{return _name;}

set{_name = value;}

}

public int Attr1{

get{return _attr1;}

set{_attr1 = value;}

}

public int Attr2{

get{return _attr2;}

set{_attr2 = value;}

}

public int Attr3{

get{return _attr3;}

set{_attr3 = value;}

}

}

 

then use the database to fill a collection of these.

List<MyObject> coll = new List<MyObject>();

foreach(some stuff from databse){

 MyObject obj = new MyObject();

obj.Name = name from database

obj.Attr1 = attr1 from database

obj.Attr2 = attr2 from database

obj.Attr3 = attr3 from database

}

 Then bind this new collection to the dropdown list

dropdownlist1.DataSource = coll;

dropdownlist.DataBind;

doing this will then give you the data item on post back of the via use of ListItem.DataItem so you don;t have to have all that information on the display

0
aquillin
6/26/2008 5:53:03 PM

Sorry, I missed the fact that you needed it in javascript.  My previous post will not give you that data on the client side.

YOu could do 2 things...

1. add AJAX to call back to the server to get the extended data you need.

2. add custom attributes to the option object that are displayed out <- this is a hack, and using AJAX would be perferred.

0
aquillin
6/26/2008 5:55:25 PM

When you binding data to list box you can substring the data and use one part in text property of listbox for display  and use other part in value property in of the same row for later use.


If it solves your issue please mark this posting as "Answered".

Thanks.
0
marx
6/26/2008 5:56:36 PM

Great that works fine the value and text property ! Thank you.

Just one other thing : I also have to bind data into a DropDownList, in asp.net this time. And as before, I need data for display and hidden data. How to bind in this case.

For the moment, I do:

ddlList1.DataSource = this.GetLstMachines()

ddlList1.DataBind();

 

I'd like to do something like:

ddlList1.DataTextSource = this.GetLstMachinesText();

ddlList1.DataHiddenSource = this.GetLstMachinesHidden();

ddlList1.DataBind();

 Thank you for advance.


David.
0
david4444
6/27/2008 7:24:28 AM

just use:

ddlList1.DataSource = this.GetLstMachines()

ddlList1.DataTextField = "TextProperty"

ddlList.DataValueField = "ValueProperty"

ddlList1.DataBind();

 

For the TextProperty and ValueProperty you will want to replace it with the name of the Property or Method on the object that is return within the collection returned by this.LstMachines().  Or if this.LstMachines retuerns a table, then use the column name which gives the correct data.

0
aquillin
6/27/2008 1:03:57 PM

If your this.GetLstMachines() returnes datatable then I would read the datatable using for loop and I would substring each record in to two parts and would add each item by stting the text and value property of the dropdown list item. 


If it solves your issue please mark this posting as "Answered".

Thanks.
0
marx
6/27/2008 3:12:58 PM

Thank you for your help.

My GetLstMachine() function returns a List<string>, so I'll try to return 2 lists:

- 1 for the TextField

- 1 for the ValueField

It should work. I'll give you feed back as soon as it's Ok.

 

Thank you.


David.
0
david4444
6/30/2008 8:54:58 AM
Reply:

Similar Artilces:

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: http://msdn2.microsoft.com/en-us/library/ms178139.aspxAlso: http://msdn2.microsoft.com/en-us/library/ms178140.aspx might ...

how to open a web page in form of a popup web page
Hello, I have two web pages, let say. Page A : With a Button on it. PAge B: with some info. Now I need to: When I click on the Button of page A.Page B must open in a pop up window.  I can do this but problem is this when I clicked on the button for first time it does not show me any thing and when I clicked on the button for second time then It shows me Page B .My code is as follow:  1 protected void Page_Load(object sender, EventArgs e) 2 { 3 if (!this.Page.IsPostBack) 4 { 5 6 } 7 else 8...

web web web
Name: bahadir Email: sensiz_olmuyor_t1_at_hotmail.com Product: Firefox 2 Beta 2 Summary: web web web Comments: web sayfası yapmak Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; tr; rv:1.8.1b2) Gecko/20060821 Firefox/2.0b2 ...

i web page referencing another web page
Can one web page reference a control on another web page? EX. a page is brought up with a number of textbox controls. Using a hyperlink one can pop up a nother page with the calendar control. Select a date from the calendar control and place the value back in the previous page. Can this be done and how? Use a Page.RegisterClientScriptBlock to open a window, with a javascript string like this: "<script language=Javascript>window.open('my_url.aspx','window_name','left=100,top=100,width=200,height=500,toolbar=no,scrollbars=yes,resizable=yes');</script>" Then you can s...

parent web page --child web page
Dear Developers , how to get values child web page values to parent web page ? For the example , I have parent Employee Address. and child Page have employee personal address.. when i access the Parent page , there is no employee address means ..child page pop rises , after complete child page then only , i can access the parent page.. how to i do .. Thanking u raja Thanks,Regards,Rajamsrasa@yahoo.com...

link a web page to another web page?
I have a web page with my banner and buttons for my site on it. I want to add this to all of my pages. Instead of copying a pasting that to every page. Is there a way i can link the pages to the banner page? Thanx use ascx?:) Or you could create a template page. That is: Create a page inherited from System.Web.UI.Page and place your banner and buttons in this and then have all your other pages inherit tis custom page instead of System.Web.UI.Page. ...

Web page .aspx is slow when loading. Pages have web user controls on them that are loaded dynamically
I have written a web application using VS 2003. Several of my forms have web user controls on them. The controls are loaded dynamically at runtime. The problem is that the web pages are very slow to load. Does anyone know if there is a way to speed up the pages being loaded into the browser? Here is an example of some code I use to dynamically load the controls:  private void Page_Load(object sender, System.EventArgs e)  {   // Put user code to initialize the page here   // Put user code to initialize the page here    Co...

All web pages hang on web server when one of the web pages calls a run away sql query
Hi: We have a Windows 2003 dedicated web server running the .NET Frameworks 1.0 and 2.0.  We have a SQL Server cluster running SQL Server 2000.  Unfortunately, we do not have a test environment.  I have 2 .NET web sites in production.  My coworker has a voting .NET web page using AJAX on the same server.  The coworker wrote a query that was not indexing properly and when the page fired the query...the cluster went to almost 100% utilization.  My two web pages would hang and show a blank white page on the default.aspx.  Neither of m...

want to allow create new web page and edit exiting web page using my web application?
 I am using asp.net 2.0 VS 2005 pro edition. I want to make web application(web form)  where my uses can go and create simple web page or can create page , so then can add page/edit features let me know if some one know , how to do this , any idea, I want to allow my user to create web page and edit web page using my web applications. some one tell me how to do that Note : I dont want to use HTMl editor or any third party software tools thank you maxmax Hello, There is many ways you can implement this. And to build your application you to need to understand the exact ou...

how can you display another web site's web page in your web page without leaving your site
Can you display another web site's web page in your web page without leaving your site? I know you could use a frameset with .asp, but it looks like Visual Web Delevoper 2005 does not have any controls to setup a frameset. Any help, that would point me in the right direction would be great. Thanks Patrick     With screen scraping 4GuysFromRolla.Com: Screen Scrapes in ASP.NEThttp://www.4guysfromrolla.com/webtech/070601-1.shtmlThanks,Teemu KeiskiFinland, EU Thank you. This information was a great help!!! Thanks again Patrick...

Could PB .NET Web Form POST security Information to others web page??
This is a multi-part message in MIME format. ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi,=20 Have anyone came across the requesion to POST security informations from = PB .NET web form web page to other web site?? I have tried many datys, Could any kind man give me some suggessions?? thanks & Best regards Leon ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML P...

Encrypt web application/ web site (all web pages)
Hello, I want to encrypt (secure) the whole web site when it is deployed on a remote server. Is there a way in ASP.NET 2.0 / IIS / 3rd party tool to encrypt all web pages that will render it useless for a competitor if they get it?I did look up this forum and google and did not find anything (though I will keep looking). Please respond if you know anything about it. Thanks,vp Please click "Mark as Answer" if you think this post answers your question Yes and no.  First, you can't encrypt web pages.  Those are HTML and displayed in the client's brow...

how to navigate the url page in one web application page to another web application page
In my project one solution have 2 web apllications in one folder.like 1.webapplication1 2.webapplication2. in firt webapplication1 i created one aspx page like sample.axpx. in second webapplication2 i created one aspx page like sample2.aspx... in sample2.aspx page have hyperlinl. I need to navigate this hyperlink when i click it go to the sample.axpx. how can i write navigate url for this...help me. ..thanks  As i understand u, you need Multi Project soltuionsee this link, http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/archive/2006/02/19...

Validation of viewstate MAC failed / Invalid data when posting from https web page to http web page
Hi, We have some web pages under https  and some web pages under http websites. When I am posting from a web page from https to http I am getting Validation of viewstate MAC failed, Invalid data HttpException. Do I need to set same Machin config section in https and http?  Can anyone help me? Thanksnut Hi, Read this post http://forums.asp.net/t/955145.aspx?PageIndex=1 regards,  Amjad Ahmad...

Web resources about - How to store in a web page dynamic data in a web Page ? - asp.net.web-forms

Dynamics - Wikipedia, the free encyclopedia
Brownian dynamics , the occurrence of Langevin dynamics in the motion of particles in solution (e.g. a grain in water, as was first seen by Brown); ...

Datacenter Dynamics
Datacenterdynamics for data center information, conferences, news, videos, whitepapers and reports globally

Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find ...
Dynamic Chiropractic - chiropractic, news, articles, research & information for chiropractors - Find a Chiropractor

Paul Melville: a dynamic talent taken before his time
What might have become of a popular young cricketer with the world at his feet?

Walmart's Everyday Low Prices Face Amazon's Dynamic Price Push
... low prices" strategy is becoming an everyday price-adjustment strategy. In what seems to be a direct response to Amazon's sophisticated dynamic ...

Mea Culpa: Confidence Proceedings Edition: I Really Do Think Dynamic Scoring Is a Bad Idea
... *Brad DeLong noted that when he was a Treasury political appointee, one of the Treasury career staff economists lectured me him about dynamic ...

dynamic billboards to up your photo game
NYC is one of the most photographed places in the world, especially this time of year. And while Instagram has made every one of us feel like ...

SNL perfectly captured the dynamics of the Republican presidential race
The "Saturday Night Live" recap of the latest Republican presidential debate reflected fairly accurately the state of the GOP primary. Beck ...

Yolanda Foster explains her divorce: ‘chronic illness changed our dynamic’
... is extremely challenging, not only for the person that’s sick, but also for the caregiver,” Foster admitted. “It for sure changed the dynamic ...

CES 2016 TV tech: 4K yawns, high dynamic range dawns
... Show in Las Vegas this January, TVs with 4K resolution are old hat. So what's new hat? The next-generation TV technology known as high dynamic ...

Resources last updated: 12/27/2015 10:40:00 PM