I am using jquery tabs(First,Second,Third) in multiple asp.net pages (First.aspx, second.aspx,Third.aspx) in my asp.net website and in each page i am writing the ul,li code.
For example in the First.aspx page I am writing the following code inside the 'ul' tag
<li class="current">First tab</li>
<li>Second tab</li>
<li>Third tab</li>
Similarly in the second.aspx,Third.aspx pages i am using the Class="current" to highlight the selected tab.Recently we have planned to move to Master pages.So the master page should contain the ul,li code for the tabs.But the problem is that I do not understand how to apply the class="current" to the selected tab,in the case of the master page.Could someone please help?
Thanks in advance.
Write a javascript function in your master page to set the current class on a tab. Each page can then call that function when it's loaded to set the current page.
Something like:
<li id='tab1'>First tab</li>
<li id='tab2'>Second tab</li>
<li id='tab3'>Third tab</li>
function setCurrentTab(selectedTab) {
$('li').removeClass('selected');
$('[id=selectedTab]').addClass('selected');
}
and in Second.aspx, for example:
setCurrentTab('tab2');
Related
I have a list in asp.net like this:
<ul id="menu" runat="server">
<li class="theMenu">Menu 1</li>
<li class="theMenu">Menu 2</li>
<li class="theMenu">Menu 3</li>
<li class="theMenu">Menu 4</li>
</ul>
I want to add a class to a list item when it is clicked using VB.net. So the user can see what menu item is the "active one" Just like it is done using jQuery:
$(".theMenu").click(function() {
$(this).addClass("Active");
});
How do you do this using VB.net???
Just use the jQuery. Really. Doing this from VB.Net means you have to cause a PostBack, and that means completely re-creating your page on the server. You don't want to do that more than you have to. It adds load to your server, and adds latency to your page responses.
I suspect you also want to know later on which item is marked as active, so I also suggest combining this with an <asp:HiddenField> control, and add a line to the jQuery to also set the value of the hidden input created by the control. Later on, when you need to know in VB.Net which list item was marked as active, you can just check the Hidden Field.
I have a menu in my Site.Master file whose code is as follows;
<nav>
<ul id="css3menu1" class="topmenu">
<li class="topfirst"><span>Home</span>
<ul>
<li>Employee Login</li>
<li>Customer/Distributor Login</li>
</ul>
</li>
<li class="topmenu"><span>Products</span>
<ul>
<li>Page1</li>
<li>Page2</li>
<li>Page3</li>
</ul>
</li>
<li class="topmenu"><span>Investor Info</span>
<ul>
<li>Quarterly Filings</li>
<li>Press Releases</li>
<li>Investor Updates</li>
<li>Company Presentations</li>
<li>Management Team</li>
</ul>
</li>
</ul>
</nav>
When I go to the sites login page BUT do not login and try to go to any of the links in the menu I get a 404 error page which says I'm trying to redirect to /Account/Page1.aspx.
Why is the "Account/" getting inserted into that path when the path from the Site.Master is clearly only Page1.aspx. I've tried changing the href to ~/ and ../ infront of the page name but that produced different types of errors ALTHOUGH it did properly redirect ONLY when in the login page (which is in the Account folder)
When you access Login.aspx page It will in 'Account' Folder directory. When you try to access other links in menu, it will first check in current 'Account' directory if page is exist it will display page otherwise it throws error.
I suggest you require dynamic menu for this. when You access 'Account' directory page it will change the menu as per the 'Account' directory and link.
You can use literal control and Literal1.Text = 'HTML Menu Code'
Better practice to use the tilde symbol instead of a relative path but with this you will need to use the
runat="server"
in the tag.
what were the other errors you got with that approach?
edit
<li><a runat="server" href="~/Account/Login.aspx">Employee Login</a></li>
It was far easier, and much more practical solution to use Page.ResolveURL("~/Account/Login.aspx"). I used Page.ResolveURL for all the links in the menu and now it works seamlessly
I need to create a custom control that spits out the the following html:
<ul>
<li>
link button
</li>
<li>
link button
</li>
</ul>
I need the links to be LinkButtons and output inside the li elements.
What is the best way of going about building this control?
You can do that using built-in DataBound Controls like ListView Or Repeater controls.
You can add LinkButton within the li tags.
Other resources:
http://www.asp.net/aspnet-35/videos/the-listview-control
I am using ckeditor to save my texts... (asp.net mvc)
In the database the text are stored like this:
<ul><li>List item</li><li>List item</li><li>List item</li></ul>
And when I am running my website I want it look like this:
List item
List item
List item
But the text are the same as in the database:
<ul><li>List item</li><li>List item</li><li>List item</li></ul>
And the source code are:
<ul>
<li>
List item</li>
<li>
List item</li>
<li>
List item</li>
</ul>
What am I missing?
Your text is being HTML encoded, if for example you're using <%: Prop %> this will happen, if you want it to render exactly, you want <%= Prop %>. There are a dozens of ways to get HTML into a page so I'm not sure exactly which method you're taking, but whichever way it is, it's passing through the Html encoder along the way.
Keep in mind storing the text and displaying it like this does render your site vulnerable to cross-site scripting and other attacks, so you will probably want to sanitize the incoming HTML.
Try using Server.HtmlDecode:
http://msdn.microsoft.com/en-us/library/hwzhtkke.aspx
What is the quickest way to test validity of any xhtml css code snippet (not whole page} in W3C validator? and give link of that test in forum/question/discussion.
code snippet like this
<ul>
<li>Item one</li>
<li>Item two</li>
<li>Watch, you can easily nest list items: This item has some sub-items</li>
<ul>
<li>Sub-item one</li>
<li>Sub-item two</li>
<li>Shall we do a 3rd nested list?</li>
<ul>
<li>OK</li>
<li>Your browser should automatically use different bullet styles for each level.</li>
</ul>
</ul>
</ul>
Look at the extra options in the validator, there is one to validate a HTML fragment. Bookmark this to jump straight to it: http://validator.w3.org/#validate_by_input+with_options
You can't post a link to the validation output, because validating by direct input uses POST (through form submit), not GET (though URL). The only way to "share" the validation is to validate by URI.
You could keep a "template" HTML file on your computer with a doctype and <body> tag (look at what the fragment validation I mentioned above adds to your code), upload that file to a folder in your web space and share the validation link for that.