master-pages

Twitter bootstrap + asp.net masterpages, how to set navbar item as active when user selects it?

笑着哭i 提交于 2019-11-28 22:58:36
问题 We are in se same situation as question Make Twitter Bootstrap navbar link active, but in our case we are using ASP.net and MasterPages... The thing is the navbar is defined at the masterpage and when you click a menuitem you are redirected to the corresponding child page so how would you do to change the navbar active item consecuently without replicating the logic in each child page? (Preferably without session variables and javascript only at master page) 回答1: We solved it with the

Parser Error: '_Default' is not allowed here because it does not extend class 'System.Web.UI.Page' & MasterType declaration

余生长醉 提交于 2019-11-28 22:23:01
I recently converted a website project to a web application project in Visual Studio 2008. I finally got it to compile, and the first page (the login screen) displayed as normal, but then when it redirected to the Default.aspx page, I received an error: Parser Error Message: 'SOME.NAMESPACE.MyApplicationName.WebApplication._Default' is not allowed here because it does not extend class 'System.Web.UI.Page'. All of my pages inherit from a class called "BasePage" which extends System.Web.UI.Page. Obviously the problem isn't with that class because the login.aspx page displays without error, and

jquery: find element whose id has a particular pattern

空扰寡人 提交于 2019-11-28 15:47:16
I am trying to find a span element who has an id in a particular pattern. Its main use is to find certain elements rendered by an asp.net (aspx) page which is derived from a master page. xxxxxxx $('span').each(function(){ if( $(this).attr('id').match(/pattern/) ) { // your code goes here } }); problem solved. Building on the accepted answer: It depends on what kind of pattern you're looking for. If your pattern is something like "MasterPageElement_CheckBox_4443", "MasterPageElement_CheckBox_4448", etc. then you could also use: $("span[id^=MasterPageElement_CheckBox]") There are 3 built-in

How to call content Page function from Master Page

早过忘川 提交于 2019-11-28 12:26:58
It is necessary to call content Page function from Master Page. Please let me know if more data needed. MasterPage.master.cs looks like protected void Required_Function(object sender, EventArgs e) { // call Update_Content_Page() from content page } Default.aspx looks like <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="contentPlaceHolder" Runat="Server"> <asp:Label ID="Label1" runat="server" Text="Label">Hello people!</asp:Label> </asp:Content> Default

find control in page

▼魔方 西西 提交于 2019-11-28 12:07:08
HTML <body> <form id="form1" runat="server"> <asp:Button runat="server" ID="a" OnClick="a_Click" Text="apd"/> </form> </body> Code protected void a_Click(object sender,EventArgs e) { Response.Write(((Button)FindControl("a")).Text); } This code works fine. However, this code: HTML <%@ Page Title="" Language="C#" MasterPageFile="~/Student/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Student_Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat=

Using FindControl to get GridView in a Content Page

喜你入骨 提交于 2019-11-28 10:22:18
问题 I would like to find a GridView Control within a separate class and I am having issues doing so. I even tried placing my code in the aspx.cs page to no avail. I keep getting Object reference not set to an instance of an object. I'm sure there is a simple step I'm missing, but in my research I cannot seem to find anything. Aspx code <asp:GridView ID="GridView1" EnableViewState="true" runat="server" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4"

Can I change a nested master page's master dynamically?

£可爱£侵袭症+ 提交于 2019-11-28 10:08:44
Okay, so we all know about changing a master page dynamically in a page's OnPreInit event. But what about a nested master page? Can I change a master's master? There is no OnPreInit event exposed in the MasterPage class. Any ideas? Just tested this and it works from the PreInit of the Page that is using the nested MasterPage. protected void Page_PreInit(object sender, EventArgs e) { this.Master.MasterPageFile = "/Site2.Master"; } Obviously you will need to ensure that the ContentPlaceholderIds are consistent across the pages you are swapping between. We combine Andy's method with a "BasePage"

ASP.NET MVC - View with master page, how to set title?

浪尽此生 提交于 2019-11-28 09:06:42
What is prefered way of setting html title (in head) for view when using master pages? One way is by using Page.Title in .aspx file, but that requires in master page which can mess with HTML code. So, lets assume no server side controls, only pure html. Any better ideas? UPDATE: I would like to set title in view NOT in the controller or model. In our master pages, we created both an "init" ContentPlaceHolder, and a "title" ContentPlaceHolder. If someone wants to programatically set Page.Title, they can set it in CSharp in the init placeholder, or they can override the "title" placeholder using

How do I get ‘footer’ content on a master page to push down when main content doesn't fill a page

橙三吉。 提交于 2019-11-28 08:42:11
问题 I have the following code for my masterpage: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server" style="position:relative"> <title>Masterpage</title> <asp:ContentPlaceHolder id="head" runat="server"> </asp

a page can have only one server-side form tag

∥☆過路亽.° 提交于 2019-11-28 08:20:43
I am using master page and when I run this page, it shows the following error message: a page can have only one server-side form tag How can I solve this problem? Naveen Desosha I think you did like this: <asp:Content ID="Content2" ContentPlaceHolderID="MasterContent" runat="server"> <form id="form1" runat="server"> </form> </asp:Content> The form tag isn't needed. because you already have the same tag in the master page. So you just remove that and it should be working. It sounds like you have a form tag in a Master Page and in the Page that is throwing the error. You can have only one. Does