[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp menu

Posted on 2012-08-23
3
Medium Priority
?
682 Views
Last Modified: 2012-09-03
hey guys i am building a menu from data base

here my code

<asp:Menu ID="mnu" runat="server" MaximumDynamicDisplayLevels="10" CssSelectorClass="myMenu" Orientation="Horizontal" OnMenuItemClick="mnu_MenuItemClick">
                                    <DataBindings>
                                        <asp:MenuItemBinding DataMember="MenuItem" TextField="Text" ToolTipField="ToolTip" NavigateUrlField="NavigateUrl" ValueField="Id" />
                                    </DataBindings>
                                </asp:Menu>

the problem i am having the when i populate a node NavigateUrl == "" they is a problem?

the click method on my menu keep refreshing my page when the url coloum in my table is null.

please help me change that to nothing if the NavigateUrl is empty to #

here my view source code of my page

<div class="myMenu" id="ctl00_mnu">
	<div class="AspNet-Menu-Horizontal">
			<ul class="sf-menu">
				<li class="sf-with-ul">
					<a href="javascript:__doPostBack('ctl00$mnu','b1')" class="sf-menu-link" title="PRODUCTS">
						PRODUCTS</a>
					<ul style="visibility:hidden; display:none;">
						<li class="sf-with-ul">
							<a href="javascript:__doPostBack('ctl00$mnu','b1\\2')" class="sf-menu-link" title="Industrial / Domestic Gases">
								Industrial / Domestic Gases</a>
							<ul style="visibility:hidden; display:none;">
								<li class="sf-leaf">
									<a href="javascript:__doPostBack('ctl00$mnu','b1\\2\\183')" class="sf-menu-link" title="Industrial Gases">
										Industrial Gases</a>
								</li>
								<li class="sf-leaf">
									<a href="javascript:__doPostBack('ctl00$mnu','b1\\2\\184')" class="sf-menu-link" title="LP / Domestic Gases">
										LP / Domestic Gases</a>
								</li>
							</ul>
						</li>
						<li class="sf-with-ul">
							<a href="javascript:__doPostBack('ctl00$mnu','b1\\3')" class="sf-menu-link" title="Welding Machines / Torches /Spares">
								Welding Machines / Torches /Spares</a>
							<ul style="visibility:hidden; display:none;">
								<li class="sf-with-ul">
									<a href="javascript:__doPostBack('ctl00$mnu','b1\\3\\7')" class="sf-menu-link" title="MIG Welding Machines">
										MIG Welding Machines</a>
									<ul style="visibility:hidden; display:none;">
										<li class="sf-leaf">
											<a href="product.aspx?name=migmax-210-amp-/-220v-inverter-type&amp;category=mig-welding&amp;id=1" class="sf-menu-link" title="Migmax 210 amp / 220v Inverter type">
												Migmax 210 amp / 220v Inverter type</a>
										</li>
										<li class="sf-leaf">
											<a href="product.aspx?name=migmax-255-/-220v-(inverter-type)&amp;category=mig-welding&amp;id=2" class="sf-menu-link" title="Migmax 255 / 220v (Inverter type)">
												Migmax 255 / 220v (Inverter type)</a>
										</li>
										<li class="sf-leaf">
											<a href="product.aspx?name=mig-welder-250-amp-/-380v&amp;category=mig-welding&amp;id=3" class="sf-menu-link" title="Mig Welder 250 amp / 380v">
												Mig Welder 250 amp / 380v</a>
										</li>
										<li class="sf-leaf">
											<a href="product.aspx?name=mac022a&amp;category=mig-welding&amp;id=4" class="sf-menu-link" title="MAC022A">
												MAC022A</a>
										</li>
										<li class="sf-leaf">
											<a href="product.aspx?name=mac023&amp;category=mig-welding&amp;id=5" class="sf-menu-link" title="MAC023">
												MAC023</a>
										</li>
										<li class="sf-leaf">
											<a href="product.aspx?name=mac024&amp;category=mig-welding&amp;id=6" class="sf-menu-link" title="MAC024">
												MAC024</a>
										</li>
										<li class="sf-leaf">
											<a href="product.aspx?name=mac032&amp;category=mig-welding&amp;id=7" class="sf-menu-link" title="MAC032">
												MAC032</a>
										</li>
								

Open in new window

0
Comment
Question by:JCWEBHOST
3 Comments
 
LVL 15

Expert Comment

by:rajeeshmca
ID: 38328007
Hi,

While you retrieve from the Database, just make the null values to # like...

Select Isnull(NavigateUrl, '#') from tablename

Regards
Rajeesh
0
 

Author Comment

by:JCWEBHOST
ID: 38328103
i tried that

select id, parent_id, title ,Isnull(url, '~/#') from menu

but none of my links are working
0
 
LVL 23

Accepted Solution

by:
Roopesh Reddy earned 2000 total points
ID: 38330067
Hi,

You can achieve it with simple jQuery snippet!

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">
        $(document).ready(function () {
            $('a').each(function () {
                if ($(this).attr('href') == "" || $(this).attr('href') == "#") {
                    $(this).attr('href','javascript:void(0);');
                }
            });
        });

    </script>

Open in new window


Place the above code at the end of the page!

Hope it helps u...
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question