473,322 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Navigation bar in asp.net

Hi,

I've created html websites before and used javascript
menus.

I'm now currently creating an aspx website. Is there a
way to write a simple navigation. e.g. mouseover a link
and get a list of navigation subitems. Can it also use
stylesheets? As you can tell, i'm a bit confused.

If anyone can point me in the right direction, i'd be
really grateful.

thank you.

Captain BirdsEye
Nov 17 '05 #1
2 3944
Captain Birds Eye,

An ASPNET application exist from a serverside application and a client side
userinterface which is handled by a browser.

There are two methods.
Where is in the aspx page a kind of scripting
Where is an aspx page that references to a dll

In both cases is that created page not returned to the browser. From the
ASPX page is a kind of HTML page created that includes JavaScript (or VBS).

You are able to add from your application JavaScript to that page. By
instance to controls with the attributes property or to add functions by the
page.registerstartupscript

However JavaScript is used on the client side (it is generated as well from
your application). Therefore when you want a menu, by instance created with
buttons, which change there colour or whatever when hoovering, than you have
to do that with JavaScript because the mouse is not on the serverside.

I hope this gives some idea's

Cor
Nov 17 '05 #2
4guysfromrolla ( http://www.4guysfromrolla.com ) have a good site with lots
of ASP.NET answers. They show how to make a rollover button which I used as
a basis for controls used on my company site at http://www.ramuseco.com.

I created a web control that is used as a navigation bar and used this same
control on all of the pages. I upgraded it a bit.

The rollover button emits javascript to the client which handles the
rolllover effects. I include it's source code after my signature.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

-----------------------------------------------------------------------------------------

/// <summary>

/// Summary description for RolloverButton1.

/// </summary>

[DefaultProperty("Text"),

ToolboxData("<{0}:RolloverButton runat=server></{0}:RolloverButton>")]

public class RolloverButton : System.Web.UI.WebControls.LinkButton

{

string _mouseOffUrl="";

string _selectedUrl="";

bool _selected;

[

Bindable(true),

Description("The image shown when the button is in a selected state."),

Category("Appearance")

]

public string SelectedUrl

{

get

{

return _selectedUrl;

}

set

{

_selectedUrl=value;

ViewState["SelectedUrl"]=value;

}

}

[

Bindable(true),

Description("When true this shows the selected image instead of the mouseoff
image"),

Category("Appearance")

]

public bool Selected

{

get

{

return _selected;

}

set

{

_selected=value;

if(value)

ViewState["MouseOffUrl"]=_selectedUrl;

else

ViewState["MouseOffUrl"]=_mouseOffUrl;

}

}

[

Bindable(true),

Description("The image shown when the mouse is not over the button"),

Category("Appearance")

]

public string MouseOffUrl

{

get{

return _mouseOffUrl;

}

set{

_mouseOffUrl=value;

ViewState["MouseOffUrl"]=value;

}

}

[

Bindable(true),

Description("The image shown when the mouse is over the button"),

Category("Appearance")

]

public string MouseOverUrl

{

get{

if(ViewState["MouseOverUrl"]==null)

return string.Empty;

return ViewState["MouseOverUrl"].ToString();

}

set{ViewState["MouseOverUrl"]=value;}

}

protected override void RenderContents(HtmlTextWriter writer)

{

if(this.MouseOffUrl!=string.Empty)

{

Image i=new Image();

i.Attributes["name"]=this.ClientID+"_img";

i.ImageUrl=this.MouseOffUrl;

i.AlternateText=this.Text;

i.ToolTip=this.ToolTip;

i.RenderControl(writer);

}

else

base.RenderContents (writer);

}

protected override void OnPreRender(EventArgs e)

{

if(ViewState["MouseOverUrl"]==null)

ViewState["MouseOverUrl"]="";

if(ViewState["MouseOffUrl"]==null)

ViewState["MouseOffUrl"]="";

if(ViewState["SelectedUrl"]==null)

ViewState["SelectedUrl"]="";

string ImageLoadScript = "RollOverBuilder"+this.ClientID;

string scriptBlock=string.Format(

"<script language=\"JavaScript\">\r\n"+

" <!--\r\n"+

" {0}_mouseoff = new Image();\r\n"+

" {0}_mouseoff.src = \"{1}\";\r\n"+

" {0}_mouseover = new Image();\r\n"+

" {0}_mouseover.src = \"{2}\";\r\n"+

" {0}_selected = new Image();\r\n"+

" {0}_selected.src = \"{3}\";\r\n"+

" // -->\r\n"+

"</script>",this.ClientID,ViewState["MouseOffUrl"].ToString(),ViewState["MouseOverUrl"].ToString(),ViewState["SelectedUrl"].ToString());

Page.RegisterClientScriptBlock(ImageLoadScript,scr iptBlock);

this.Attributes["onmouseover"]=string.Format("display('{0}_img',
{0}_mouseover)",this.ClientID);

this.Attributes["onmouseout"]=string.Format("display('{0}_img',
{0}_mouseoff)",this.ClientID);

if(!Page.IsStartupScriptRegistered("displayScript" ))

Page.RegisterStartupScript("displayScript",

"<script language=\"JavaScript\">\r\n"+

" <!--\r\n"+

" function display(imgName, imgUrl)\r\n"+

" {\r\n"+

" if(document.images && typeof imgUrl != 'undefined')\r\n"+

" document[imgName].src = imgUrl.src;\r\n"+

" }\r\n"+

" // -->\r\n"+

"</script>");
base.OnPreRender (e);

}

}
-----------------------------------------------------------------------------------------

"Captain BirdsEye" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi,

I've created html websites before and used javascript
menus.

I'm now currently creating an aspx website. Is there a
way to write a simple navigation. e.g. mouseover a link
and get a list of navigation subitems. Can it also use
stylesheets? As you can tell, i'm a bit confused.

If anyone can point me in the right direction, i'd be
really grateful.

thank you.

Captain BirdsEye

Nov 17 '05 #3

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

Similar topics

4
by: Dave Patton | last post by:
Using my About page as an example: http://members.shaw.ca/davepatton/about.html What is the best/proper way to markup a page such as this that has "the main body" and "a navigation menu"? It...
0
by: Veli-Pekka Tätilä | last post by:
Hi, My first post here. I've found some serious accessibility flaws in the Python 2.4 docs and wish they could be rectified over time. I'm very new to Python and initially contacted docs at python...
1
by: Robert Neville | last post by:
I am having some trouble with some old code revolving around custom form navigation buttons. My main form has a sub-form with these custom navigation buttons. In other words, the code should be...
4
by: Sandy.Pittendrigh | last post by:
I don't want to get into a frames discussion here. We all know they have numerous drawbacks, especially with search engine visibility. (Google, ironically, uses framesets for displaying individual...
28
by: laredotornado | last post by:
Hi, Surprisingly, I can't get the drop down menus to work on PC IE 6. If you roll over "PRODUCTS", normally a drop down menu appears (on Safari and Firefox), but on PC IE, nada. ...
3
by: Paul | last post by:
I want the <div id="navigation"column to be the same color all the way to the bottom. The "background-image: url(bg_menu_tile.gif);" was a try to force it with a long 1-pixel graphic - didn't...
10
by: EA | last post by:
I am sure I must be missing something about building navigation bars with CSS. Yes it is a very clever and efficient way to format navigation structures on simple one navigation level webs, i.e....
1
by: quartzy | last post by:
I have a strict doc type: However, I am still unsure about css. Problems I have now are to do with floating both navigation lists. I have used tables and divs, as layouts are just too difficult for...
0
by: emalcolm_FLA | last post by:
Hello and TIA for your consideration. I have created several db's for a non-profit and they want custom navigation buttons to display "You are on the first record, last record, etc". With this...
0
by: tom59593 | last post by:
Hi there. I have been attempting (for a few days on end, sadly) to get a navigation section of my new site to work. Granted, this is the first time I've ever written CSS...although I had PLENTY of...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.