I'm working on aspx pages and i have asp.net Menu and CSS assigned to it.
But when I run the application the CSS class names get changed and its dynamically created as we see in controls inside "ContentPlaceHolder".
The code is
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu"
EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal">
<DynamicItemTemplate>
<%# Eval("Text") %>
</DynamicItemTemplate>
<Items>
.
.
.
</Items>
</asp:Menu>
please check this Image what i get when i run this..
I checked my application to know whether the Menu control is placed inside content placeholder or anything. But its not.
Do anyone know how to solve this issue.
class="menu ct100..." means that this element has two classes 1:menu and 2:ct100...
and nothing is wrong with it!the ct100... is generated by asp.net and if it is different any time you run the page it's up to asp.net component and if you dont like that try not to use this built in component, that i think you should do it.
by the way the only thing is changing when using master pages is client side id, that you can avoid this from happening by code below
<asp:TextBox ID="myId" runat="server" ClientIDMode="Static"></asp:TextBox>
set ClientIDMode to Static
Related
I have created these links using asp: linkbutton, like this
<li id="lhome" runat="server" class="active"><asp:LinkButton ID="btnhome" runat="server" OnClick="btnhome_Click" href="#home" PostBackUrl="~/Index.aspx">Home</asp:LinkButton></li>
<li id="lservice" runat="server"><asp:LinkButton ID="btnservice" runat="server" href="#works" OnClick="btnservice_Click" PostBackUrl="~/Index.aspx">Services</asp:LinkButton></li>
<li runat="server" id="llogin"><asp:LinkButton runat="server" ID="btnlogin" OnClick="btnlogin_Click" PostBackUrl="~/Login.aspx">Login</asp:LinkButton></li>
My first page is Index.aspx which consists of home, about, services and other sections on a single page I can go to any of these sections directly from the same page. But if I am on the Login.aspx then on clicking these links just redirects me to the Index.aspx but not to the specific section. I tried almost everything but it didn't help.
This is my Index.aspx page:
I tried using this and when clicked on Home on Login.aspx
<li>About</li>
got this result:
the whole design got disturbed.
Please help how I can redirect to Services or About or other sections on Index.aspx from Login.aspx or other pages with the same header. I have created this navbar using asp.net UserControls and used it on both the pages.
I can't make my question more specific.
Please help!
i have a .aspx page, where i have some user controls, nested inside <table> tags, some of them are link this:
<td runat="server" id="LoadContext" class="tb_RightTD">
<cc1:RMWDropDownMenu ID="ddLoadContext" CssClass="ddLoadContext" CaptionCssClass="lbContext" CaptionExpandedCSSClass="lbContextExpanded" ImageCssClass="lbContextImage" ImageExpandedCSSClass="lbContextImageExpanded" runat="server" DropDownContentsBoxWidth="0px" DropDownMenuCellCssClass="DropDownMenuCell" DropDownMenuItemCssClass="DropDownMenuItemCssClass" DropDownMenuItemHoverCssClass="DropDownMenuItemHoverCssClass" DropDownMenuTableCssClass="DropDownMenuTable" meta:resourcekey="ddLoadContextResource1" TableCssClass="dropDownTable" Value="" DropDownContentsPanelId="" ExpandImagePath="" TableExpandedCssClass=""></cc1:RMWDropDownMenu>
</td>
i can't understand how this works, because, i'm just changing the "frontend", and... this code generates a table soup with some links inside. i want change the structure of this "dropdown" and in his place, use bootstrap structure, to make it look better, i need some help to override this thing, i know php, but asp is not my beach.
folder structure image
here the page i'm editing: http://pastebin.com/kgsMk2mH
I am trying to display a table on the button click,right below the button,but it is getting display on the top of the page(Above the navbar).
This is what I did:
Response.Write("<table border='1' cellpadding='2' WIDTH='20%' height='10px' style=\"margin-bottom:10px\">");
what should be done to align the table below the button?please help
you should place a control and that add it into that control.
You can also take the help of html generic controls to add html control in the controls.
<asp:panel id="panel1" runat="server">
</panle>
and in code behind
panel1.InnerHtml="";
You should not be using Response.write. Either:
1) Use some JavaScript and HTML to show/hide the table.
2) Use server side control for example
ASPX page
<asp:panel runat="server" id="foo" visible="false">
<table border='1' cellpadding='2' WIDTH='20%' height='10px' style=\"margin-bottom:10px\>
....
<asp:panel>
Code
foo.Visible = true;
See Show/Hide panels in ASP.net C# after submitting form
So, my boss has this crazy idea - the whole website working on one single page. So far - still ok, but here's the thing:
- the different pages have different divs with content (like usual), and when some div is clicked (or link in it) some of the divs expand/collapse, working in the way of revealing different content. That's fine, but...
he doesn't want to use JavaScript or anything for dynamic view of the website ('cuz I am leaving in 2 weeks and him and the other employee are not capable of JS, thus cannot improve/maintain if needed)
his idea is to have the HTML code, for all the pages variations of the website, stored in the database, and upon clicking some link - reloading the page with the certain HTML. So not different .html files for every page, but only one for all of them.
The problem is that it works for the first page that I load, initially, but then when I call another page, it gets twisted, since I call the function, that retrieves the HTML, but the other call of the previously loaded page is still there, so it calls again. Here's sample, so you understand:
<script runat="server" type="text/C#">
public string getPage(string name)
{
string page = "null";
switch (name)
{
case "media":
page = getMediaPage(); <!-- just function from the code-behind that retrieves the html code from the DB and passes it to the page -->
break;
case "home":
page = getHomePage(); <!-- just function from the code-behind that retrieves the html code from the DB and passes it to the page -->
break;
}
return page;
}
</script>
</head>
<body onload="addEvents();">
<form id="form1" runat="server">
<div id="parent">
<div id="presentation">
SomeCompany ApS Street3 | CITY | INFO#Comapny.com TLF: 999999
</div>
<%=getPage("home") %>
</div>
</form>
So that's how the initial page will be and then just in the parent div I will call the HTML for the other pages. One example of HTML, stored in the DB:
<div id="mainmenu">
<b>HOME</b>
<br />
PRODUCTS
<br />
SUPPORT
<br />
CONTACT
<br />
ABOUT
<br />
</div>
<div id="logo">
</div>
So I call this chunk of code slam it in the page. The twist happens as I have <a href="<%=getPage("media")%>"> clicked, so it loads the page normally, but there is <%=getPage("home") %> standing statically in the page, ALL THE TIME, as I need to start from somewhere, and it attempts to load the previous page again, and... server error.
I know it's kinda stupid idea, but I can't argue with him anymore.
So my question is - is there way of handling all this with some kind of OnClick(Event e) or some other way out, with calling different functions (as I already started).
Or I should just tell the boss that it's not gonna work this way...
As stated, this isn't a great idea, but you could get it to work by using some Web Controls.
Where you have <%=getPage("home") %> in your page, change this to:
<asp:literal id="ltlContent" runat="server" />
On Page_Load call:
ltlContent.Text = getPage("home");
Any links on your page which should load other content, change these to LinkButton controls, and their click events could have:
<asp:LinkButton id="linkMedia" runat="server" onclick="LoadContent" CommandArgument="media" />
public void LoadContent(object sender, EventArgs e){
ltlContent.Text = getPage(e.CommandArgument);
}
you could try the parameters on the get url.
add them on your link "?page=media"
and then you parse the url when you arrive $_GET["page"]
I have been using Bootstrap for a while now and love it. Saves me a bunch of time. I just started with KnockoutJS and as it happens, I have to combine the two at a rather granular level. My Knockout object(s) are filling a results table. When I just want the values (like Name) it is working great. However, I want to put an icon (icon-pencil for you Bootstrap people) in front of my link so it stands out as something to edit. I am using ASP.Net (not MVC) but I suspect that is not an issue.
Here is some code that works (but has no icon):
<asp:LinkButton ID="lbtEditGenerator" runat="server" data-bind="text: GeneratorName, click: function() { EditGeneratorClick(GeneratorID) }"></asp:LinkButton>
However, I want to add the following code just in front of the "GeneratorName" to get me the pencil icon. I need it to be within the text property so it is part of the LinkButton:
<i class='icon-pencil'></i>
Combining them in the bind-data (as follows) throws a parsing error:
<asp:LinkButton ID="lbtEditGenerator" runat="server" data-bind="text: <i class='icon-pencil'></i> GeneratorName, click: function() { EditGeneratorClick(GeneratorID) }"></asp:LinkButton>
Aside from creating a new property on my object that combines the two values, is there a way to do this with the Knockout binding?
Have you tried something along these lines:
<asp:LinkButton ID="lbtEditGenerator" runat="server" click: function() { EditGeneratorClick(GeneratorID) }">
<i class='icon-pencil'></i>
<span data-bind="text: GeneratorName"></span>
</asp:LinkButton>
Alternatively, you can put the <i> element before the <asp:LinkButton>. The solution above allows you to click either on the icon or on the text to trigger the button.