Web Forms :: Can Modify The Properties Of A Content Page Control From An Event Fired From The Master Page?

Feb 25, 2011

Can I modify the properties of a content page control from an event fired from the master page?create a delegate and event on master page wire up the master page in the content page create the event handler (function) on the content page modify for example:

contents of the Text property of a textbox render a control visible (or hidden) etc...

View 4 Replies


Similar Messages:

AJAX :: How To Access Master Page Dropdownlist Control SelectedIndexChanged Event Inside The Content Page

Mar 20, 2010

i want to give id of dropdowncontrol inside master page, how can i assign this control id in trigger of updatepanel inside content page

View 1 Replies

Web Forms :: Access Public Properties Of Master From Content Page?

Mar 9, 2010

Here's the scenario: A class based on System.Web.UI.Page has been created. A number of content pages derive from this class. All of these content pages use the same master page. The content pages define controls which need to access things on the master page (in code-behind). This is fine - no problem. In particular, each content page has its own data grid. The grid on each page has the same name, so that common code can reference it. In fact, some event handling for the grids on each content page is identical, so would like to factor that code to the base class. Interestingly, I can actually define the event handler entirely in the base class, with no stub in the content class at all, because the wire-up of event handlers uses the event-handler name defined in the grid, and that name happens to be found in the inherited base class. All good and dandy... very cool in fact. The problem comes when the code in the base class needs to access any of the common elements from the content page's master. Remember, the master is the same, and I know the type of the master. I would like to do something like this in the base-class code:

((myMasterType)this.Master).PropertyofMaster=xxx;

The problem is, that myMasterType - the type of the master page the content pages are using - is not available at compile time, at least not from a class definition for a base page. I've found articles that claim that the class name of the master is available - and it is, but not from a separate class. I CAN see it and compile with the master's class name from, for example, the code behind of the various content pages. But the actually class simply isn't available, it seems, from a pure class (the base page class). Judging from other times this question has been asked, here are common misunderstandings offered as solutions: 1. Use a page directive to declare the master type. This is not even vaguely a part of the problem, as the issue is not code in the content page, but in a separate base class which content pages inherit from. That base class is a pure class -- no .ASPX file at all. 2. Pass a reference to the master object from the content page to the base class. This can be done, but is pointless, because I can already get it, using "this.Master" from the base class! But because the type of the master is not available at compile time from the base class, it can't be passed from the content page either - unless it is passed with type MasterPage, thus losing all the properties/methods publically defined in the specific master page class. 3. Move the base page class out of the App_Code folder because the app_code folder is compiled before the other classes, and thus before the master page class. Doesn't work -- put the master page class file right in the same folder with these content pages and their master page, and the master page class is still not available at compile time from within the class. Re-summarized: Base page inherited by content pages. Content pages all use a common master page. Want to access the public properties of that master page from the base page, at runtime. Barrier is that I can find no way from within the base class to cast the master page object to the actual master page subclass being used.

View 7 Replies

Best Way To Set Master Page Properties In Content Page?

Sep 1, 2010

There are different ways to set the title for content pages from Master page

by findcontrol by creating property in master page and setting the value in content page

As both method requires an object creation of master page which will be little heavy
myMasterPage myMaster = (myMasterPage)this.Master;

so I have tried it by creating a class and it worked -

public class clsmaster
{
public static clsmaster objmaster = new clsmaster();
public strtitle {get;set;}
}

Now I just need to access this static object and set the property in the content page and in the master page I just need the controls to take the value from this class (clsmaster).

View 2 Replies

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

How To Run The Javascript Function On The Page Onload Event In Content Page Of Master Page

Nov 4, 2010

HOW TO RUN THE JAVASCRIPT FUNCTION ON PAGE ONLOAD EVENT IN CONTENT PAGE OF MASTER PAGE.?

means i have masterpage and the content page of master page namely default.aspx in vb.net

My problem was that .

i wanna run javascript function in Default.aspx and i have called the function

body onload in master page..

when i run my website it shows the error

"" Microsoft JScript Runtime Error : Object Expected ""

View 4 Replies

Web Forms :: Pass Data From Master Page PageLoad Event To Content Page PageLoad Event

Oct 21, 2015

I have a masterPage on that i am using AjaxModalPopup for login purpose.My requirement is when  i login via Master page then it should show the Logged-in User details on the current Content Page that is using same master page.

Here i am using following code to get it back to the same content page after succesful login but it does not show the user details on the same content page rather when i go to next page then it appears.

 if (Session["SignedIn"] == null)
{
ValidateUser();
ModalPopupExtenderMaster1.Hide();
string currentPageUrl = System.IO.Path.GetFileName(Request.Url.AbsolutePath);
Server.Transfer(currentPageUrl);
}

But it does not gives user-details on the same content page.

View 1 Replies

How To Disable Controls Of Master Page Used In Content Page While Processing Some Event

Jun 24, 2010

The following code works fine for disabling content page controls, but how do I disable master page controls?

public void DisableControls(Control control,bool isEnable)
{
if (control.HasControls())
{
foreach (Control c in control.Controls)
{
DisableControls(c, isEnable);
}
}
else
{
if (control is IPostBackDataHandler && !(control is IPostBackEventHandler))
{
if (control is WebControl)
{
((WebControl)control).Enabled = isEnable;
}
else if (control is HtmlControl)
{
((HtmlControl)control).Disabled = !isEnable;
}
}
}
}

View 2 Replies

User Control Properties That Located In Master Page From A Child Page?

Jan 11, 2010

I have user control that is part of a panel that located in my master page in every page i need different setting for that user control.

for example in page 1 i need to set the AutoPostBack property to true but in page 2 i need it to be false.

so my question is how can i user control properties that located in master page from a child page?

View 9 Replies

User Controls :: How To Call Event Of Button Inside UserControl In Master Page From Content Page

Apr 25, 2014

I have a ShoppingCart UserControl on MasterPage. I have a following functionality: User adds item to the cart. after clicking the button "Complete Sale" in UserControl the page is redirected to "CustomerInfo.aspx" and after filling the Customer information and clicking on submit which is on CustomerInfo.aspx page i want to call the "Complete Sale" click event of UserControl from "Customerinfo.aspx" page.

Customerinfo.aspx.cs
protectedvoid btnSubmit_Click(object sender, EventArgs e)
{
try
{
bool val = false; int retVal = 0;
CustomerBiz objCust = newCustomerBiz();
objCust.FirstName = txtFirstName.Text.Trim();

[code].....

Here the Button text changes in UserControl. But i am not able to call the Click event of this button from CustomerInfo.aspx (ContentPage)?

View 1 Replies

How To Handle Master Page Button Event In Content Page

Apr 20, 2010

My problem is this I have a base page that creates content dynamically. There are buttons on my Master Page that fire events that my base page needs to know about. But the OnLoad function on my base page fires before my Button_Command function on my master page. So I either need to figure out a way to load my base page after the Button_Command function has had the chance to set a variable or I must call a function in my base page from the Button_Command function.

View 3 Replies

Master Page And Content Page Event Firing Sequence?

Aug 22, 2010

When master page event fires, content page events are fired first,

is there any content page event that fires after the master page events.

View 1 Replies

Web Forms :: How To Call A Javascript Function On A Master Page From A Content Page Control

Jan 24, 2011

I have a javascript function on my Master page, how do I access it with a dropdownlist of a content page. Not from codebehind, I can do that, but from the control itself such as the onSelectedIndexChanged event.

View 11 Replies

Web Forms :: How To Remove Master Page Prefix From Control ID After Rendering Content Page

Jun 26, 2010

how to remove master page prefix from control ID after rendering content page

i m using master page in my web application, i am using a java script that works on one of my div id and i am genrating div at run time using C# code, problem is that one one of my content page rendred a prefix ct100 attached on that div,

How can i remove that prefix from my server side control (assume panel) id

View 2 Replies

Web Forms :: How To Use StaticSelectedStyle In Menu Control With Master Page/Content Page

Jan 14, 2010

I have a MasterPage where I use the menu control. Clicking a menu item loads a new content page. That part works fine.

I would like to use staticselected style to change the look of the selected menu item. However, when the new content page loads, the staticselectedsyle formatting does not work.

View 6 Replies

Web Forms :: Access User Control Of Master Page In The Content Page

Jan 27, 2010

I have a user control in the master of my website and I want change some property of that control from the content page.

View 3 Replies

Web Forms :: How To Reference A Control On A Master Page From A Content Page Code-behind

Aug 5, 2010

I am attempting to access a textbox control on a master page from a code behind base class but having problems.

I have 3 levels of master pages. m1.master is the master page for m2.master which is the master page for m3.master.

m3.master has a textbox as shown below

<%Master
Language="C#"
MasterPageFile="~/m2.master"
AutoEventWireup="true"
CodeFile="M3.master.cs"
Inherits="M3"
%>
<asp:Content
ID="Content5"
ContentPlaceHolderID="M2"
Runat="Server">
<asp:TextBox
ID="text1"
runat="server"
></asp:TextBox>
<asp:ContentPlaceHolder
ID="M3"
runat="Server"></asp:ContentPlaceHolder>
</asp:Content>

I have a content page c1.aspx that uses m3.master as its master page as shown below:

<%@
Page
Title=""
Language="C#"
MasterPageFile="~/m3.master"
AutoEventWireup="true"
CodeFile="c1.aspx.cs"
Inherits="_c1"
%>
<%@
MasterType
VirtualPath="~/m3.master"
%>
<asp:Content
ID="Content1"
ContentPlaceHolderID="M3"
Runat="Server">
</asp:Content>

My content page codebehind class inherits from a base class BaseForm

public partial
class
_c :
BaseForm{}

The problem that i am having is that I cannot access the texbox from the class BaseForm. The BaseForm code is as follows:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public...........

I'm getting a null reference exception for txt1

View 8 Replies

Web Forms :: Find Hyperlink Control In Master Page From Content Page?

May 7, 2015

I have hyperlink in page

<asp:HyperLink ID="HyperLink1" runat="server" class="lblMenuMessage" NavigateUrl="~/Admin/صندوق-پیام.aspx">صندوق پیام</asp:HyperLink>

and css

.lblMenuMessage
{
float:right;
text-align:right;
width:150px;
margin:0 12px 0 0;
color:white;
text-decoration:none;
}

and I want change it's color in behind code so I wrote:

(this.Master.FindControl("HyperLink1") as HtmlGenericControl).Style["color"] = "black";

but below error happen:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: 

Line 13:
Line 14: (this.Master.FindControl("ADMenuMessage") as HtmlGenericControl).Style["background-image"] = Page.ResolveUrl("~/Image/ADactivmenu.png");
Line 15: (this.Master.FindControl("HyperLink1") as HtmlGenericControl).Style["color"] = "black";
Line 16: }
Line 17: }

how I can change hyperlink textcolor in behind code?

View 1 Replies

Web Forms :: Access Control Declared In Master Page In Content Page

Dec 8, 2012

How to access a control declared in a Master Page in a content page.I have a ModalPopUpExtender in Master Page and i want to access it from a content page, how can i do that.

View 1 Replies

Web Forms :: What Is The Syntax For Finding A Control In A Content Page From Javascript Code In The Master Page

Jan 16, 2011

I have a control in a content page that I want to find the width and left attributes of the style. I am trying to find this from Javascript code that exists on the Master Page. How do I do that?

View 1 Replies

Override Master Page Event In Content Page

Nov 16, 2011

I have all my site navigation done in my master page. However, I have one page where if they make changes I set a set a flag that I want to use makes them save or cancel the changes before they can navigate away from the page. How do I go about for just that single page overriding the Master Page navigation events?

View 5 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

Web Forms :: Can't Access A Control In The Master Page From A Content Page

Dec 16, 2010

Does any know why I can't access the my custom user control StatusBar which is declared inside a masterPage?

In the ContentPage, I tried referencing the control this way "this.Site.stastusBar" and "this.Master.Status" and neither one works. Both instellisense warns me that "statusBar" does not exist.

Below is my Aspx code and code-behind:

[code]....

View 3 Replies

Web Forms :: Getting Value From User Control In Master Page In Content Page

May 11, 2010

There need to read selected value from drop down list which is in user control (user control is placed in master page) in contect page.

View 1 Replies

Web Forms :: Access Master Page Control Value On Content Page?

Mar 25, 2010

on master page, i have declared a label control & set value to it.now on content page, i m able to find the control, but the value is alwasy null & not the one which was set.when i debugged, content page's load event is called first, after that the master page is called.so where should i access the master page control so that i get the set value.

View 4 Replies







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