| | |
How can I fill the webpage
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
Hi,
I want to fill data from database on the webpage. There's no problem with reading the data, filling the menu and so on, but I want to put the text & pictures in the article and this is a real problem :lol: Is there some component (like panel or something) where I can put text with HTML formatting & maybe some pictures?
Thanx,
S
I want to fill data from database on the webpage. There's no problem with reading the data, filling the menu and so on, but I want to put the text & pictures in the article and this is a real problem :lol: Is there some component (like panel or something) where I can put text with HTML formatting & maybe some pictures?
Thanx,
S
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
Use the code. This is the whole point of asp.net. You build a webpage on the fly and the asp.net engine will then convert it to html to output to the browser.
Each requirement is different, but you can put any webcontrol on a webpage and give it a value or text (Depending on the control) at run time in page load or other methods. Placeholders, images, textboxes, labels, grids, datalists, the list is endless.
An example would be to give a label some value:
Or you can bind in the markup using <%# Eval("columnname", {optional format}) %> tags
Each requirement is different, but you can put any webcontrol on a webpage and give it a value or text (Depending on the control) at run time in page load or other methods. Placeholders, images, textboxes, labels, grids, datalists, the list is endless.
An example would be to give a label some value:
ASP.NET Syntax (Toggle Plain Text)
Label1.Text = DataRow1["label1text"].ToString();
Or you can bind in the markup using <%# Eval("columnname", {optional format}) %> tags
Yes, we definitely don't understand ourselves
Usually when you want to add text into (for example) panel, you just can write some text, maybe with some hyperlinks etc. in the designer, and then you'll just compile that. But I'm trying to make a dynamic webpage, so I don't want to add any text into panel before compilation. So the whole thing will work this way:
1) I'll design a new webpage in the designer with menus & graphics, but without any text
2) User will call a webpage using the parameter (for example something like this: www.mypage.com/myform.aspx?page=1 )
3) I'll read the requested data from the database (already in HTML) & fill the webpage - here's the problem - panel component don't have a "Text" attribute so I can't add text there on the fly. And I can't use the Label, because this component don't allow me to add any hyperlinks into text, or make a new line whenever I want
Notice not everything in the page is loaded from database. Parts like menu and graphics are pre-defined and looks the same on all generated pages.
Usually when you want to add text into (for example) panel, you just can write some text, maybe with some hyperlinks etc. in the designer, and then you'll just compile that. But I'm trying to make a dynamic webpage, so I don't want to add any text into panel before compilation. So the whole thing will work this way:1) I'll design a new webpage in the designer with menus & graphics, but without any text
2) User will call a webpage using the parameter (for example something like this: www.mypage.com/myform.aspx?page=1 )
3) I'll read the requested data from the database (already in HTML) & fill the webpage - here's the problem - panel component don't have a "Text" attribute so I can't add text there on the fly. And I can't use the Label, because this component don't allow me to add any hyperlinks into text, or make a new line whenever I want

Notice not everything in the page is loaded from database. Parts like menu and graphics are pre-defined and looks the same on all generated pages.
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
Ok it is easy and now i understand. The website in my signature is purely made up of code on the fly. Here are some options for you:
Create a panel or placeholder or other such component on your blank page where you want information to go.
On page load read the information from the database and create the relevent controls (labels, images, hyperlinks etc) and add them to the panel.controls. You can apply styles and everything in code just as you would with a normal asp server web control.
The asp.net engine will render the controls as normal. (The only difference you have made between on the fly and using the designer is that the IDE puts the code in the InitializeComponent method where as you have it in page load or some similar method, but the code is the same.
Using panels and other containers renders a <div> tag in html. It also means you can have anything you like in there and will be decided depending on data from the database at run time. Use this if you are not even sure what controls you will need at run time.
If you know what you need but not sure of their values until you get the data at run time then place the controls on there but fill their values from the database when you get the information.
Remember both cases you can apply clientside scripts on the fly at runtime also using the Attributes value for the web control (eg. Mybutton.Attributes.Add("onmouseover", "somejavascriptfunctionname");
Finally (one of my favorite controls) the Literal control lets me put whatever i want in a certain place. I often use this to place an html (as opposed to web server) control on my page in a certain place but am not sure of the control until runtime but know where it wants to go. The literal control will let me put just about any text i like in there so i can put a whole table or just a label or span or anything i like at runtime.
I also use this a lot to post to 3rd party sites where they expect a control with a certain name (if you use a web server control asp.net renames it to make it unique so you have problems). eg paypal will want a hidden control named "amount" for the purchase amount. If you create a label asp.net will rename it in the rendering as ctl001$amount or something similar to ensure it is unique. I need to fill the amount from the database or somewhere so i use a literal with the following code
this will render the html markup as if i typed it in the source and no renaming.
Hope these help? Let me know what you need to do (eg unsure of controls until data is present or just need to fill controls with data etc) and i will shed some more light if you need it
Create a panel or placeholder or other such component on your blank page where you want information to go.
On page load read the information from the database and create the relevent controls (labels, images, hyperlinks etc) and add them to the panel.controls. You can apply styles and everything in code just as you would with a normal asp server web control.
The asp.net engine will render the controls as normal. (The only difference you have made between on the fly and using the designer is that the IDE puts the code in the InitializeComponent method where as you have it in page load or some similar method, but the code is the same.
Using panels and other containers renders a <div> tag in html. It also means you can have anything you like in there and will be decided depending on data from the database at run time. Use this if you are not even sure what controls you will need at run time.
If you know what you need but not sure of their values until you get the data at run time then place the controls on there but fill their values from the database when you get the information.
Remember both cases you can apply clientside scripts on the fly at runtime also using the Attributes value for the web control (eg. Mybutton.Attributes.Add("onmouseover", "somejavascriptfunctionname");
Finally (one of my favorite controls) the Literal control lets me put whatever i want in a certain place. I often use this to place an html (as opposed to web server) control on my page in a certain place but am not sure of the control until runtime but know where it wants to go. The literal control will let me put just about any text i like in there so i can put a whole table or just a label or span or anything i like at runtime.
I also use this a lot to post to 3rd party sites where they expect a control with a certain name (if you use a web server control asp.net renames it to make it unique so you have problems). eg paypal will want a hidden control named "amount" for the purchase amount. If you create a label asp.net will rename it in the rendering as ctl001$amount or something similar to ensure it is unique. I need to fill the amount from the database or somewhere so i use a literal with the following code
ASP.NET Syntax (Toggle Plain Text)
litHiddenAmount1.Text = @"<input name='amount' type='hidden' value='" + myCart.Total + "' />";
Hope these help? Let me know what you need to do (eg unsure of controls until data is present or just need to fill controls with data etc) and i will shed some more light if you need it
![]() |
Similar Threads
- Can not fill dataset from database on other computer with ASP .NET and MS Access (Visual Basic 4 / 5 / 6)
- help with writing CGI!! (Perl)
- How do i get other webpage and parse ! (PHP)
- Search not working right... (Viruses, Spyware and other Nasties)
Other Threads in the ASP.NET Forum
- Previous Thread: newby wants messenger type login options
- Next Thread: SQL SERVER 2000 Login failure in ASP.NET
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# cac checkbox child class compatible complex content contenttype control countryselector courier database datagrid datagridview datalist deployment development dgv dialog dropdown dropdownmenu dynamic dynamically edit editing embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv folder form gridview gudi iis image javascript languages list maps menu mobile mssql nameisnotdeclared novell opera order parent problem profile ratings redirect refer registration relationaldatabases reportemail response.redirect rows search security select serializesmo.table sessionvariables silverlight smoobjects software sql ssl tracking treeview typeof validatedate validation vb.net vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xsl





