473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Master Page / Content Page interaction question

My master page has a drop down list of languages. When the user
selects a new language, I would like to call a method in the currently
loaded content page to load all the fields with text in the chosen
language. My current approach is in the Content page to hook into the
SelectedIndexChange event of the dropdown list (ID is ddlLanguage), but
I am not receiving the event (see code below). Is there a better way
to do this? Alternately, could I handle the event in the master page
codebehind and call a method in the currently loaded page? There will
be several content pages, so they would all support the method.

Thanks in advance,
JPan

// Page_Load() on Content page
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// all this code seems to work without a problem
langDDL = (DropDownList) Master.FindControl("ddlLanguage");
langDDL.SelectedIndexChanged += new
EventHandler(langDDL_SelectedIndexChanged);
}
}

// Event handler - also on Content page (not being called!)
public void langDDL_SelectedIndexChanged(object sender, EventArgs
e)
{
// set UI culture, change text of each control, etc.
}

Jul 10 '06 #1
1 2876
You need to subscribe the content page to the event during postbacks, not
during the first time where the page loads.

The correct code will be
// Page_Load() on Content page
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack)
{
// all this code seems to work without a problem
langDDL = (DropDownList) Master.FindControl("ddlLanguage");
langDDL.SelectedIndexChanged += new
EventHandler(langDDL_SelectedIndexChanged);
}
}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"jpan" <jp**@pocketlearn.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
My master page has a drop down list of languages. When the user
selects a new language, I would like to call a method in the currently
loaded content page to load all the fields with text in the chosen
language. My current approach is in the Content page to hook into the
SelectedIndexChange event of the dropdown list (ID is ddlLanguage), but
I am not receiving the event (see code below). Is there a better way
to do this? Alternately, could I handle the event in the master page
codebehind and call a method in the currently loaded page? There will
be several content pages, so they would all support the method.

Thanks in advance,
JPan

// Page_Load() on Content page
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
// all this code seems to work without a problem
langDDL = (DropDownList) Master.FindControl("ddlLanguage");
langDDL.SelectedIndexChanged += new
EventHandler(langDDL_SelectedIndexChanged);
}
}

// Event handler - also on Content page (not being called!)
public void langDDL_SelectedIndexChanged(object sender, EventArgs
e)
{
// set UI culture, change text of each control, etc.
}

Jul 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Herman \(Parallelspace\) | last post by:
1. What are some compelling solutions for using Master/Content pages with Web Pages? 2. If a content area has a web part zone with web parts, what is the user experience like when "editting" the...
2
by: Learner | last post by:
Hello, This is first time I have started using Master Pages. I am using ASP.NET 2.0 (VB) in Visual Studion 2005. This is how I am doing it... I have created a master page and placed a...
17
by: Rob R. Ainscough | last post by:
Again another simple concept that appears NOT to be intuitive or I'm just stupid. I've read the WROX book and the example doesn't actually show how the .master page links in the other content...
2
by: Paul | last post by:
Hello: I am struggling with something that would seem to be very easy. I am using a master page. On the content page (which includes the master page), I have a form with a submit input type...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
2
by: Stratum | last post by:
It's an old question, and I apologize for raising it again. I use ImageButton objects on my ASP.Net master page to navigate to content pages. For each button, I have two images. One image shows...
4
by: lichaoir | last post by:
I have two questions about the use of Master Page: 1. How to access properties and controls in the master page from content page? (I know I can use the "FindControl()" method of the "Master"...
2
by: John | last post by:
Hi, I'm having trouble with nested master pages (and creating the same behaviour as Scott Guthrie's blog post...
6
by: Mickey | last post by:
Coming from a Dreamweaver/ASP/PHP background. Planning to use Visual Studio 2008 for a website. Complete newbie question here (please be gentle!): Do master pages work similar to Dreamweaver...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.