I want to have 4 links in the sidebar of master page which every other form (content page) in my web application inherits.
<table>
<tr>
<td width= "150px">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<asp:Menu runat="server" ID="MainMenu1" CssClass="MasterContent" StaticSubMenuIndent="30px">
<Items>
<asp:MenuItem Text="My Software" NavigateUrl="~/MySoftware.aspx"></asp:MenuItem>
<asp:MenuItem Text="Check Out" NavigateUrl="~/CheckOut.aspx"></asp:MenuItem>
<asp:MenuItem Text="View Shopping Cart" NavigateUrl="~/ShoppingCart.aspx"></asp:MenuItem>
<asp:MenuItem Text="Continue Shopping" NavigateUrl="~/Start.aspx"></asp:MenuItem>
</Items>
</asp:Menu>
</asp:ContentPlaceHolder>
</td>
<td width="900px">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
This is the content in the master page as you can see there are 4 menu items i tried to form as sidebar and i tried to inherit in home.aspx(one of the content pages) as follows:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Start.aspx.cs" Inherits="WebStore._Start"
MasterPageFile="~/Webstore.Master" %>
<asp:Content ID="StartSideBar" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
But unfortunately the sidebar is not at all getting displayed. I know i'm doing fundamentally wrong some where. My intention is to have web pages to have sidebar like this. It is a screenshot of my intended page.
Can some one guide me through this.
Thanks in anticipation
The way you have it set up, your home.aspx file is clobbering your menu links because it is defining the content of ContentPlaceholder1 to be empty (or something else at any rate), which is overriding the menu links you put in your MasterPage inside the same content holder. The way MasterPages and content pages work is that the MasterPage defines a location (a ContentPlaceholder) for the content page (e.g., home.aspx) to load content into. But you have put actual content you want to keep inside a ContentPlaceholder on your MasterPage--which means that any content page (again, like home.aspx) that defines content for ContentPlaceholder1 (like you do with StartSideBar) is going to override anything defined inside ContentPlaceholder1 on the MasterPage--in this case, your menu links.
If you want your menu links to remain constant on every content page, then you should move them out of ContentPlaceholder1 on the MasterPage and make them just markup on the MasterPage (in fact, you should probably remove ContentPlaceholder1 altogether). The easy way to do this is to comment out the ContentPlaceholder tag itself like this:
<table>
<tr>
<td width="150px">
<%--<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">--%>
<asp:Menu runat="server" ID="MainMenu1" CssClass="MasterContent" StaticSubMenuIndent="30px">
<Items>
<asp:MenuItem Text="My Software" NavigateUrl="~/MySoftware.aspx"></asp:MenuItem>
<asp:MenuItem Text="Check Out" NavigateUrl="~/CheckOut.aspx"></asp:MenuItem>
<asp:MenuItem Text="View Shopping Cart" NavigateUrl="~/ShoppingCart.aspx"></asp:MenuItem>
<asp:MenuItem Text="Continue Shopping" NavigateUrl="~/Start.aspx"></asp:MenuItem>
</Items>
</asp:Menu>
<%-- </asp:ContentPlaceHolder>--%>
</td>
<td width="900px">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
You will also have to remove the ContentPlaceholder reference from your content page as well, or you will get a compliation error (because you removed it from the Master, it can't exist in the content page--but that's okay, the MasterPage now has the links you want):
<%# Page Title="" Language="C#" MasterPageFile="~/Webstore.master"
AutoEventWireup="true" CodeFile="Start.aspx.cs" Inherits="Start" %>
<%--<asp:Content ID="SideBarStart" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>--%>
Related
I have an .aspx in which there is one anchor tag whose href property is set by the server side code i.e. DataTable.
My site url is : [xxx/Pages/Home.aspx] and suppose the href from the DataTable is bound http://www.google.com then the link redirects to [xxx/Pages/http//www.google.com] instead of http://www.google.com . Somehow it prefixes relative url of page.
My ascx file is :
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<asp:ListView ID="Feed" runat="server">
<ItemTemplate>
<div class="Main">
<div class="Ttile">
<a href="<%# Eval("Link") %>" target="_blank" title="<%# Eval("Title") %>" ><%# Eval("Title") %></a>
</div>
</td>
</tr>
</table>
I want to redirect the user to http://www.google.com when user clicks on the link but the anchor tag redirects to http://xxx/Pages/http//www.google.com
If I put <%# Eval("Link") %> outside the anchor tag then it displays the proper url like : http://www.google.com. It means the data in "Link" column is perfect
How should I tackle this issue?
try this one
<%# RemoveServerUri(Convert.ToString(DataBinder.Eval(Container.DataItem, "Link")))
C#
public string RemoveServerUri(string link)
{
link = link.Replace("xxx/Pages/", "");
return link;
}
I have a masterpage like this
<%# Master Language="C#" MasterPageFile="~/masterpages/XmasShop.master" AutoEventWireup="true" %>
<asp:Content ContentPlaceHolderID="cphContents" runat="server">
<asp:LoginView runat="server" ID="lview1">
<LoggedInTemplate>
<div class="confirmation-cantainer">
<div class="confirm-01">
<form runat="server">
<umbraco:Macro Alias="[Xmas]ShopConfirm" runat="server"></umbraco:Macro>
</form>
</div>
</div>
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>
<asp:Content ContentPlaceHolderID="cphAuthenticationPane" runat="server">
<asp:LoginView runat="server" ID="lview12">
<LoggedInTemplate>
<form runat="server">
<asp:LoginStatus ID="lslougout" runat="server" Style="float: right; color: #003263; text-decoration: none;" text="Logout"></asp:LoginStatus>
</form>
</LoggedInTemplate>
</asp:LoginView>
</asp:Content>
And you can see I have two form tags in it,but both are seperate not nested.Still I am getting an error
A page can have only one server-side Form tag.
Can any one suggest me a solution.When I tried to remove one of the forms its throwing an error elements must be inside a form tag and when I add form above error.
Use the following tutorial to set up two form tags and be able to toggle them on and off, as required:
http://jerschneid.blogspot.com/2007/03/hide-form-tag-but-leave-content.html
One solution is to have the login information on a separate page. You could also look into using an iframe.
This error occurred due to use of more than one
<form runnat="server">
tag.
Remove one of the form tag.
This would be more clear by visiting this link
I have a master page named MainMasterPage.master i have a contentplaceholder1 and contentplaceholder2. Further, i am creating a nested master page which is using the contentplaceholder1, in this i am placing the labels. But these labels are not showing up.Where am i going wrong ?
In Nested master page
<asp:Content ID="Content1" ContentPlaceHolderID="cntplace1" Runat="Server">
<table width="100%">
<tr> <asp:Label runat="server" ID="lblImmu" Text="Immunization Details"></asp:Label></tr>
<tr><asp:Label runat="server" ID="lblDel"></asp:Label></tr>
<tr><asp:Label runat="server" ID="lblMal"></asp:Label></tr>
</table>
</asp:Content>
I'm developing a facebook application, using IFrame instead of FBML. I have a main page with a sub-iFrame inside. In the inner iframe (the invitation page) I have:
<%# Register Assembly="Facebook.Web" Namespace="Facebook.Web.FbmlControls" TagPrefix="cc1" %>
<cc1:Fbml ID="Fbml1" runat="server" Xfbml="True">
<ContentTemplate>
<cc1:RequestForm ID="RequestForm1" runat="server" Method="Post" Type="Xfbml" Xfbml="True"
Invite="True" Content="Invite your friends" Action="." Visible="True">
<ContentTemplate>
<cc1:MultiFriendSelector ID="MultiFriendSelector1" runat="server" Rows="3" Xfbml="True"
ShowBorder="True" EmailInvite="True" Bypass="Cancel" ActionText="Select Friends you want to invite">
</cc1:MultiFriendSelector>
</ContentTemplate>
</cc1:RequestForm>
</ContentTemplate>
</cc1:Fbml>
This doesn't work at all and when I view the frame source, I get:
<fb:fbml>
<fb:request-form type="Xfbml" Content="Invite your friends" action="." method="POST">
<fb:multi-friend-selector actiontext="Select Friends you want to invite" showborder="true" email_invite="true" rows="3" bypass="cancel"></fb:multi-friend-selector>
</fb:request-form>
</fb:fbml>
Any ideas and/or suggestions are very appreciated. Thanks for reading anyway
When I use a ASP:Calendar control, and give it an ID:
<asp:Calendar runat="server" ID="MyCal" />
It looks like this in the rendered html:
<table id="NameMangled_MyCal"... />
And I can access the element by ID in javascript like this:
var cal= document.getElementById("<%= MyCal.ClientID%>")
However, When I make a custom user control that has-a calendar:
<%# Control Language="C#" AutoEventWireup="true" CodeFile="WeeklyEventsCalendar.ascx.cs"
Inherits="WeeklyEventsCalendar" %>
<div>
<asp:Calendar runat="server" ID="InnerCal" Width="100%" OnDayRender="RenderCell" OnVisibleMonthChanged="ChangeMonth" Height="480px" />
</div>
And then give it an ID when I add it to my page...
<mvs:WeeklyEventsCalendar ID="WeeklyCal" runat="server" />
That ID doesn't show up anywhere in the rendered HTML. all I get is
<div> stuff </div>
When I want
<div id="NameMangled_WeeklyCal"> stuff <div>
What am I doing wrong?
UserControls only render their contents, nothing else. What you could do is
<%# Control Language="C#" AutoEventWireup="true" CodeFile="WeeklyEventsCalendar.ascx.cs"
Inherits="WeeklyEventsCalendar" %>
<div id="<%= this.ControlID %>">
<asp:Calendar runat="server" ID="InnerCal" Width="100%" OnDayRender="RenderCell" OnVisibleMonthChanged="ChangeMonth" Height="480px" />
</div>