Showing posts with label static. Show all posts
Showing posts with label static. Show all posts

Monday, March 26, 2012

Newbie Data List question

OK, I'm baffled (again).

I'm a .NET noob, converting a static HTML site to one that is more dynamic. Part of the site draws a menu like this:

Photo Gallery

Europe
Critters
Family
Garden
Pumpkins
Special Events

Here's the HTML that is generating the menu:


<!--
<TABLE cellSpacing=13 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<DIV class=nav>
<P>Photo Gallery</P>
<P>
<font color=Yellow>Europe (NEW!)</font><BR>
Critters<BR>
Family<BR>
Garden<BR>
Pumpkins<br>
Special Events<BR>
</P>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
-->

Pretty simple. What I'm trying to do now is create a User Control that will now generate the menu by selecting distinct Category from tblCategories in an Access database.

But, I'm just getting really confused by where to do all of this. I think it's best to use a datalist, but where do I put the code?

- Do I put a script tag in my MenuRight.ascx file?
- Do it do it in the Codebehind for that same file?
- If I use the connection, adapter, and datalist objects from the toolbar, do I need to write script to connect to the database and bind the data, or is that all taken care of?

Right now, I can't seem to get it to display anything at all. Very frustrated!

Any help would be much appreciated.

SteveWhere to put the code, script tag or code behind? I personally prefer CodeBehind. Until you get yourself better grounded, just put it in the codebehind for your control. As you begin writing more complex applications you might want to separate out the data access into a data access layer and just pass the results back to the control.

Yes, you do need to write the code to open the connection, do the query, bind the data, etc.

Take a look at the quickstart tutorials on this site if you need more.

Saturday, March 24, 2012

Newbie Help -- .net and static HTML

Whew... hopefully my questions will get more elaborate as I use this more... this is probably as basic as I could get.
I come from a web design background... haven't done web programmingbefore barring some CFML. Now I'm responsible for coming up to speed onASP.net + VB for work needs...
So here's my basic question.
I created a graphical HTML header for a website I'm building. Iwant to make this a global header across the application, so I want tocall it in each time a page loads. Also, I have navigationbuttons that I want to be able to program VB behind to perform certainactions (mostly just page loads). I really don't know how to addthis header to my web application so as to be able to call it in...once its created, Im confident I can muddle through creating objectsfrom the buttons and programming the VB behind them that I need.
I just frankly can't figure out how to integrate the HTML header (and graphics) with the web application.
Can anyone enlighten me? I couldnt' find an article here about that, so I'm posting.
Thanks so much!
Welcome to Asp.net!
ASP.NEt provides you with the capability to create user controls. UserControls is just like a page but it does not contain the form tag. UserControls are used to divide the pages into small sections so that pageis easy to modify in the future.
So, in your case you can make a user control for the header, footer.Once the user control is created you can simply place it (Drag andDrop) on the page and thats it. Your user control can be placed in allthe pages you have. If later you want to change something in the headersection of the page you simply change the user control and thats it.Once the user control is changed it will take effect on all the pagesthat contain it.
A good tutorial isExtensive Examination of User Controls.


That's pretty much what I needed to know, thanks very much =)
I'll check out that tutorial right now. Thanks again!

Thursday, March 22, 2012

Newbie looking for help... Data driven navigation

Is it possible to generate ASP.net website navigation based entirely on SQL queries?

If so, is it better to generate a static sitemap by running these queries only when a change is made to the database,

or

is it better to allow the queries to run "realtime" on page load and whenever a link is clicked?

Sorry if I'm not too clear, I'm still "extremely" wet behind the ears. ;-)

Thanks in advance,

Jeff

Well not sure if this is the answer you are looking for, but Asp.net 2.0 has a very good new feature Site Map where you can use the Site Map Provider to configure your Navigation of your website.


Hi,

Take a look at these tutorials

http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/sitemapdatasource.aspx

http://www.asp.net/learn/data-access/tutorial-62-cs.aspx

One thing you might want to do is cache the SiteMap the first time your page load, that way you will avoid unnecessary db roundtrips.

However if your SiteMap is going to be changing all the time than you can leave the caching out.

Goodluck


The second link is exactly what I was looking for. Thanks.

The link you posted is appending an extra character though, breaking the link, so I reposted it below. (This link points to the VB tutorial)

http://www.asp.net/learn/data-access/tutorial-62-vb.aspx

Jeff