master-pages

Is ctl00 a constant in ASP NET?

霸气de小男生 提交于 2019-12-08 19:21:24
问题 I need to reference a control in my web app that was generated with the use of a master page. The name of the control in the HTML becomes something like this "ctl00$MainContent$ListBox1". Can I safely do this in the code? string strName = "ctl00$MainContent$ListBox1"; if (Request.Form[strName] != null) { String selectedLanguage = Request.Form[strName]; } PS. I cannot use ClientID property because this code is called from InitializeCulture() override. 回答1: You could, but what I do is set the

ASP.NET Web Forms: Master Page & CSS File [closed]

为君一笑 提交于 2019-12-08 16:33:35
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . I have a project (Web Application) that I need to implement with Web Forms. I have already prepared the design for the website and I will use one of the CSS templates that I already developed. In this case: Should I use a master page? Is there any relationship between the

asp:ImageButton not firing onclick event

六月ゝ 毕业季﹏ 提交于 2019-12-08 15:52:11
问题 I have a page that uses a master page, several RequiredFieldValidators, and the Web Toolkit autocomplete extender. The following code only shows the bare minimum of the page: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" MasterPageFile="~/master.master" Inherits="Login" %> <asp:Content id="Content1" contentplaceholderid="ContentPlaceHolder1" runat="server"> <asp:UpdatePanel ID="pnlUpdate" runat="server"> <ContentTemplate> <div> <asp:ImageButton class="submitButton"

Access asp:content from code behind

风格不统一 提交于 2019-12-08 15:29:25
问题 Ok, I am an experienced web developer but sometimes ASP.Net is tricking me. I have a master page in asp.net. Then I have a page based on that master page (home.aspx). Now in home.aspx.cs I want to access the asp:content controls to add controls programmatically. Aspx looks like this: <asp:Content ID="leftCol" ContentPlaceHolderID="cphLeftCol" Runat="Server"> <asp:PlaceHolder ID="phLeftCol" runat="server"> </asp:PlaceHolder> </asp:Content> I would expect that I can reference "leftCol" from my

Error: Unable to evaluate expression because the code is optimized

柔情痞子 提交于 2019-12-08 15:16:54
问题 I am getting an error in my asp.net app that reads "Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack." protected void btnCustomerProfile_Click(object sender, EventArgs e) { try { Server.Transfer("CustomerProfile.aspx"); } catch (Exception ex) { Response.Write(ex.ToString()); } finally { } } After searching SO, I see most of the similar posts involve response.redirect. My code is using server.transfer and my application is also using

How to avoid InvalidOperationException when setting the defaultbutton in ASPX content

馋奶兔 提交于 2019-12-08 06:36:07
问题 I am trying to set a default button in my ASPX page. I have a master page so the form is there. I have a panel in the content page that holds a table that organizes a number of textboxes, dropdowns and other inputs. The last row of the table holds some buttons, one of which I want to be the default button. After doing some research, I have tried the following with no success. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then

How to create create variables/properties in master page, and let sub-pages access them?

跟風遠走 提交于 2019-12-08 06:15:01
问题 How to create create variables/properties in master page, and let sub-pages access them? So my master will have a string property HomeUrl How can any page that uses the master page access this property? 回答1: You should use a base class for you master page which will define you properties: public class BaseMasterPage : System.Web.UI.MasterPage { public string HomeUrl {get; set; } } And then your master page should inherit from this BaseMasterPage class (as example): // real master page public

Twice postback in ASP.NET

為{幸葍}努か 提交于 2019-12-08 04:18:40
问题 My page is fully postback twice. I am using master page with AJAX. The structure of master page is as follows. +---------------------------------------------+ | Web User Control with AJAX Tab Control | +---------------------------------------------+ | | | | | Col1 | ContentPlaceHolder | Col3 | | | | | | | | | +---------------------------------------------+ The web user control contains the AJAX Tab Container with AutoPostback on. I have created several ASPX pages using this masterpage. The

page_load event in Master and Content Pages

北城以北 提交于 2019-12-08 03:12:21
问题 Here is the sequence in which events occur when a master page is merged with a content page: http://msdn.microsoft.com/en-us/library/dct97kc3.aspx So, my problem is: I have one login page (not use master page), one master page, and hundreds of content page. I check login session Session["loggedInUser"] in master page (if not logged in, redirect to login page) So, when I don't log in, if I type the address of one content page, it must check login session in master page and redirect to login

How To: add dynamically HiddenField in masterpage base page

淺唱寂寞╮ 提交于 2019-12-08 02:20:31
问题 I have a Base MasterPage class, from which my masterpages will inherit. I have some javascript functions there for it's child pages to include. As it's a base class, it does not have a visual designer nor I can add XHTML code. I need to add a hidden field to the class so I can set it's value in the javascript code, and when a postback occurs I can get the setted value on my content pages. Yet I fail to achieve this, for when I try to add the hidden field to the base masterpage's control