VS 2010 - Content Page Accessing Event Handlers From Two Different Master Pages

Jul 1, 2013

I have a ASP.NET content page where the master page is set dynamically. Both master pages contain a print button and an associated event handler for the click event of the button. Unfortunately I receive a run-time error when I attempt to dynamically access the event from the master page that was not initially assigned. Below are code snippets:

Page_Load():
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strPageTitle As String = "Evaluator Data Form - Instructions"
If Page.MasterPageFile.Contains("masEvaluators.master") Then
Dim mp As Evaluators_masEvaluators = CType(Me.Master, Evaluators_masEvaluators)

[code]....

which produces the following error when I load the page and reference the "masStaff.master" master page:

System.InvalidCastException: Unable to cast object of type 'ASP.staff_masstaff_master' to type 'Evaluators_masEvaluators'. at Evaluators_EDF_Instructions.Page_Load....

I can solve the problem by adding a print button to the content page, but that defeats the purpose of using a master page.

View 1 Replies


Similar Messages:

Web Forms :: Accessing Master Page From Content Page - Raising Event?

Sep 10, 2010

Here is my situation: I have a user control that has a menu in it. This user control sits on my master page. It is my main navigation menu for my application. I am having an issue where, on one of my pages, users seem to be leaving the page before committing all changes to the database, which results in a loss of data. So what I want to accomplish is - if the user is leaving this page and the data has not been saved yet, I want to prompt the user and say something like "The information is not yet saved, are you sure you want to leave this page" in a modal popup. So my approach is this: In my menu user control, create an event handler called MenuClicked that is raised when the menu web control's (in the user control) MenuItemClicked is raised, I raise my custom MenuClicked event. Then on my master page, I can catch this event in NavMenu_MenuClicked. My problem is - I need to catch this event in my content page, not the master? Am I approaching this correctly?

View 2 Replies

C# - Master Page Which Wraps The Content Pages Content In The Form, Can't Nest The Forms?

Oct 5, 2010

The WorldPay payment gateway suggests using this HTML to take the customer to the payment page:

<form action="https://select-test.wp3.rbsworldpay.com/wcc/purchase" name="BuyForm" method="POST">
<input type="hidden" name="instId" value="211616">
<input type="hidden" name="cartId" value="abc123">
<input type="hidden" name="currency" value="GBP">
<input type="hidden" name="amount" value="0">
<input type="hidden" name="desc" value="">
<input type="hidden" name="testMode" value="100">
<input type="submit" value="To Payment!">
</form>

How to I put this form on my page? The problem is I have a master page which wraps the content pages content in the ASP.net form, I can't nest the forms.

View 2 Replies

How To Add Title And Meta Tags For Content Pages In A Project Base On Master And Content Page

Oct 17, 2010

how can i add title and meta tags for content pages in a project base on master and content page(dinamically) ?

i used the blow method for master page :

[code]....

and the error is :(in line *)

Error 17 'System.Web.UI.MasterPage' does not contain a definition for 'SetMetaTags' and no extension method 'SetMetaTags' accepting a first argument of type 'System.Web.UI.MasterPage' could be found (are you missing a using directive or an assembly reference?)

View 3 Replies

Web Forms :: Accessing Master Page Content From Content Page?

Feb 16, 2010

I am having asp:hyperlinks in my master page, which i use as my page headers. I would just like to change the text format of the hyperlink when a content page is loaded.

the CS code for accessing the master page contents from content page?

View 3 Replies

Web Forms :: Master Pages - How To Access Content Page From Master Page

Sep 5, 2010

I have a master page setup that is used throughout my site that is basically a header with a menu. I recently added a textbox and a button to this master page which is to be a quick search box that is available anywhere in the site. When a user enters text into the search box and hits the button, I need to load the actual content page which is used to search and show search results (which also uses this same master page), and have the text entered available so the search can be triggered automatically. Again, this search text box and button is now in my master page so it could be triggered from anywhere in the app... it serves as a convenient way to do a basic search from anywhere in my app, without having to first navigate to the actual 'search page' that already exists. You can also navigate to the actual search page, which uses the same master page, where there is many more search options.I'm thrown off by the master page arrangement, which I have not used until this project. What do I do?

View 4 Replies

VS 2010 - Accessing Master Page Code Behind

Jan 17, 2011

I have a few pages in my web application where I would like to be able to use the code-behind of a master file, but not 'inherit' any of the other stuff like asp/html markup etc.

View 5 Replies

Web Forms :: Accessing Content Title From Master Page?

Dec 8, 2010

I've done this a bazillion times but today my mind is simply blank and because it is so easy I've no notes on it.

If I set Title="foo" in the <%@ Page directive of my content page, how do I reference it in the code behind of my master page? I need to use it in a Select Case.

I swear, if my head wasn't permanently attached, I'd have lost it somewhere today.

PS. This question is only silly because I'm asking and I should know the answer.

View 2 Replies

Web Forms :: Accessing Master Page's Body Tag From Aspx Page That Is Not A Content Page

Jan 8, 2011

I am using Master page and Content page combination.But how can i access <body> tag and it's event (onload, onunload) of Master page in .aspx page that is not a content page.

View 12 Replies

Web Forms :: Accessing Public Property Inside User Control In Master Page From Content Page

Nov 9, 2010

I have user control in the master page. user control code behind page having public property called SetValue.

Now I want to set the value from content page .

View 4 Replies

C# - Use The Same Content Page With Two Different Master Pages ?

Feb 15, 2010

I have an asp.net content page which is used inside of a master page (with header, menu and some links). I would like to reuse it in a different context without the master page (to not display the header and menu there), or with an empty master page if this is somehow possible. I don't want to violate DRY principle by taking the whole page and creating a standalone clone of it for obvious reasons. Is this somehow possible ?

View 2 Replies

Web Forms :: Batch Creation Of Content Pages (re: Master / Content Pages)

Apr 19, 2010

I have over 300 content pages to create. Each has some standard styling. I would like to generate these pages, and was just wondering if there is a utility in web developer 2008 express to do so (otherwise I will just build one - but it would be great not having to do so!)

View 1 Replies

Web Forms :: Multiple Master Pages For One Content Page?

Jan 25, 2010

Can we use 2 master pages in a single content page without nesting master pages.

View 1 Replies

Web Forms :: How Can Use Master Page Methods Into Content Pages

Mar 23, 2010

I have some of the methods in the master page,I want to inherit the master page to content page and use its methods...How will be able to do that..Do we have some techniques with inheritence?Please specify the techniques andPlease in C# with Code Behind...

View 4 Replies

Web Forms :: How Many Master Pages Can Be There For A Single Content Page

Mar 10, 2011

Can any one tell me :- How many Master Pages can be there for a Single content page at max?Describe with details why is so also .

View 1 Replies

Web Forms :: Interaction From Nested Master Pages To Content Page

Apr 12, 2010

I have 2 nested master pages, lets call them MP1 and MP2. MP1 is top level, MP2 is level

2. Then I have several content pages. Lets say I have 2 content pages for now CP1 and CP2. Each content page has a form that will have some user input and a SaveData()function that saves the data to a database. Each content page also has a "Save" button that calls the SaveData() function.

MP1 and MP2 have several link buttons. The functionality I need is this: Any time a user clicks on a link button in MP1 or MP2, the SaveData() function of the currently loaded page should be called. This is to save the data even if the user forgets to click the "Save" button before leaving the page.

So far I can do this from the link buttons in MP2. I followed the master pages tutorial # 7

In the .cs file for MP2, I declare:

public event EventHandler SaveData;

then i raise a "SaveData" event any time a link button in MP2 is clicked.in every content page (CP1, CP2 etc.) aspx file, I have Master Type directive to assign the Master Page to MP2.

in CP1, CP2 etc .cs file, i have the following code:
protected void Page_PreInit(object sender, EventArgs e)
{
//wire up the SaveData event from MP2 to Master_SaveData function in this page.
Master.SaveData += new EventHandler(Master_SaveData);
}
private void Master_SaveData(object sender, EventArgs e)
{
//when the MP2 SaveData event is raised, save the data in this page.
SaveData();
}

All of this works fine.Problem is I am not able to do a similar thing from MP1.What I have tried so far is to raise an event in MP1 that is handled in MP2. When the event is handled in MP2, it raises the SaveData event to be handled in the page. The event in MP1 is null and hence never raised.

View 5 Replies

MVC :: Master Page Is Executed Before Content Pages Controller/action?

Mar 24, 2011

I think normally the execution sequence is content page's controller first, then master page (I have some inline code).

But now I have a situation that master page's inline code is executed before content page's controller.

View 2 Replies

Web Forms :: Access Master Page Controls In Content Pages?

Dec 17, 2012

Today I got a strange problem,that is I am unable to access master page controls in its code behind,I am wonder because,I can able to access master page controls in their code behind of other projects/applications's master pages.

I know we can acess like this Label lblText = (Label)this.FindControl("lbluserName"); in that situation but I need to access div controls which are set to run at server.

View 1 Replies

Converting Content Pages To Nested Master Content Pages In .net

Jul 28, 2010

I have a main master page, say MasterPageMain, and a couple of folders with couple of pages in each folder which act as a child page to that master page - MasterPageMain.

Now, I have about 10 pages in one of the folder which follows a certain pattern and they could really use a nested pages since any change on some parts needs me to change all the pages which is a pain really.

I already added a Nested master page, say NestedMasterPage - which is a child of MasterPageMain

I tried to change one of the page's <%@ Page directive to NestedMasterPage, immediately, there were a lot of errors. plus I dint know where the NestedMasterPage's children content would go.

What do I need to know in order to do this succesfully?

ps: I dint do this initially because I only had 2 pages, and I dint need this at that time, as the project grew, now i see that I should have changed it much earlier..

View 2 Replies

VS 2010 - Stop Master Page Redraw / Only Refresh Content Page?

Jul 20, 2012

I am writing a web application which consists of a master page (header / menus) which does not change and content pages. When I do something like click on a button it causes a post back which is correct but this redraws the whole screen and becomes annoying because every post back and the whole screen flickers.

Is there a way to only refresh the content page?

View 5 Replies

VS 2010 - Change Menu Items On Master Page Depending On Content Page Selection

Feb 15, 2012

I have a master page with an unordered list that contains items like, Home, Messages etc.

Now I am working on an EditProfile.aspx page and I want the menu to change and have items like Basic Information, Profile Picture etc. Sort of like facebook. What is the best way to accomplish this...

View 2 Replies

Web Forms :: Declare Global Variable In Master Page And Use It In Content Pages

Jun 16, 2015

how to declare global variable in master page and use it in all pages

View 1 Replies

AJAX :: How To Add Accordion CSS File In Content Page When Working With Master Pages

Apr 25, 2013

i want to apply css on accordion control but since the page where i m using is already associated with master page...

when i go to my website page..i use attach style sheet and then ok..but style sheet doesn't get attach...how should i do that..?

View 1 Replies

VS 2010 - Working With Master Page From Content Page

Aug 31, 2012

I have the following in my master page:

Code:
<span id="Quote" class="hide">..........

In my code behind on the content page of page load I want to change the class="hide" to class="show" How can I do that?

View 5 Replies

Web Forms :: Accessing Control From Master Page On Asp:Wizard Step Change Event

Mar 19, 2010

My requirement is to disable a control on Master page when user is on some specific step of asp:wizard control. I am facing 2 challenges,

1. I am not able to disable the control master page by setting its Enabled property as false, this is inspite that I am getting the control object when I do a Master.FindControl("MyControlName").

2. To try and disable the control from JS, I am not able to find a JS event that would get called when a speific tab step get active and loaded.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved