C# - Dynamically Changing Master Pages / Getting Thread?

Sep 13, 2010

I created this master page file and in its Page_PreInit added the code to change master page at run time after detecing a visitor's country:-

Now, while researching I came across this thread that says "Setting the master page in Page_PreInit event is against the design and spirit of MVC..what is this supposed to mean ???

If not this way, how else am I supposed to change master pages at run time???

View 1 Replies


Similar Messages:

C# Dynamically Changing Master Pages

Sep 11, 2010

You fetch the user's IP address and based on his/her country you redirect the user to a specific webpage. Now, how do you change the master page dynamically? This is how I am redirecting the user :-

Geolocation Error with IP Address 127.0.0.1

It's not like the user clicks some button or something and you then change the master page. I want it changed when the user is redirected, so how exactly do I go about it?

public partial class testClass: System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (redirected to site1)
{
Use this master page1
}
else
if (redirected to site2)
{
Use this master page2
}
}
}

So how do I check what SITE the user has been redirected to? Also HOW to apply the specific master page now that the user has been redirected?

I just need an idea how to go about it.

[EDIT] please check the code block below. How do I fetch the URL that the user has been redirected to? I actually need just the "iso3166TwoLetterCode" variable's value (see the link to my earlier question, please) and based on that will be changing the master page. I can't figure out how to fetch that value or even use that class (that's got this variable) in my testClass.

protected void Page_PreInit(object sender, EventArgs e)
{
if (user Has been redirected to www.site.in )
{
this.MasterPageFile = "master1.master";
}
if (user Has been redirected to www.site.fr )
{
this.MasterPageFile = "master2.master";
}
}

View 2 Replies

C# - Possible With ASP.NET Master Pages To Create Content Pages Dynamically?

Jan 22, 2010

Is it possible with ASP.NET Master Pages to create content pages dynamically?That is, I know we can create content dynamically, but the content pages themselves,can those be created programmatically? I want to give my users the ability to define new content pages (i.e. Categories: Sofas, Tables, Lamps, and add/delete as they see fit) through a management panel. The resulting content pages should have proper URL naming, so that they index properly.An example: http://www.example.com/products/Lamps/contentpage.aspx.Is there a demonstration of this somewhere I can view?

View 4 Replies

Changing Urls Form With Master Pages

Jan 13, 2010

We've had a requirement from a client to move a site that is running on it's own domain to a subfolder of another app.

I've acheived this using ISAPI rewrite proxying.

However, there is one form that does a post back in the site. The generated url for the action from ASP.NET is "/sign-up.aspx?". This sends the postback to the root of the site.

I want to change this to "sign-up.aspx?" (no leading slash). This would be fine if I wasn't using Master pages as I could get a reference to the form and change it's action (this is .NET 3.5 SP1). I've tried to use the following code in my control to get a reference to the form but it doesn't seem to do anything. It finds the form but the action is not set to the value.

HtmlForm form = ControlLocator.FindControl<HtmlForm>(Page.Master.Master, "form1");
form.Action = "sign-up.aspx?";

This is in Page_Load and ControlLocator.FindControl is a port of this http://www.west-wind.com/Weblog/posts/5127.aspx

View 3 Replies

Web Forms :: Dynamically Changing Master Page

Aug 19, 2010

I'm working on a project that have 3 diffrent type of users with 3 diffrent master pages. I can verfiy there access level and let them view pages but after googling I came accross a tutorial form asp.net but it wasn't very helpfull the code I got listed below works only if the session is at null, It dosen't seem to pull the session value.

[Code]....

there is a class page attached to it but nothing seems to work. I've downloaded the tutorial but it wasn't any clearer than what I read.

I 'm just trying not to have to code over the joint pages.

View 3 Replies

C# - Loading Of Master Pages Dynamically?

Dec 16, 2010

Can we have the Masterpage loaded dynamicallu. I have a page that must be used in 2 different scenarios ie., using two different master pages.

View 2 Replies

Master Pages Host A Dynamically Generated Menu

Nov 18, 2010

There's a master page that is used by all the pages in the app. This master page hosts a dynamically generated menu. Opening of pages etc. is almost always handled through Response.Redirect(). Here's the catch:

I login to the app and it shows me a default page, with the master page at the top. So the Page_Load() fires for the master page. So far good. Now I go through the menu and select an item. Clicking the menu triggers a postback where the Page_Load() of the master page is called again. After that the Page_Load() of the desired content page is fired, and then the Page_Load() of the Master page is fired yet again! So each time I click a menu item, the master page is loaded twice!

View 7 Replies

C# - Changing Membership.ApplicationName In Code - Thread Safety

Dec 5, 2010

On the MSDN page for the Membership.ApplicationName property (which applies to an asp.net membership provider), it warns that although one can change Membership.ApplicationName in code, 'The ApplicationName property is not thread safe for multiple writes, and changing the ApplicationName property value can result in unexpected behavior for multiple users of an application.' They therefore recommend avoiding using it for a 'web application'.

This is because the default SqlMembershipProvider is written as a singleton. But here's my question: is it OK if all the threads in my application process are going to set Membership.ApplicationName to the same thing?

I'm thinking of having multiple applications on my IIS box, each with their own separate application pool. I want to point them to the same location, but based on the hostname, set the application provider to different things. Wouldn't this actually be OK? It might not be a thread-safe operation, but doesn't each application pool have its own process and therefore its own instance of SqlMembershipProvider? So, every thread that tried to set Membership.ApplicationName for a given SqlMembershipProvider instance would be trying to set it to the same thing (the provider that is appropriate for that hostname).

View 1 Replies

Cross-thread Operation Not Valid: Accessed From A Thread Other Than The Thread It Was Created On

Apr 2, 2010

I want to remove checked items from checklistbox (winform control) in class file method which i am calling asynchronously using deletegate. but it showing me this error message:-

Cross-thread operation not valid: Control 'checkedListBox1' accessed from a thread other than the thread it was created on.

i have tried invoke required but again got the same error. Sample code is below:

[code]....

View 1 Replies

Web Forms :: VS2010 Master Pages / Everything Shows On The New Pages Except The Jpeg Image Logo?

Sep 5, 2010

i'm developing a site using VS2010 and with my windows vista busniness OS. i used the default VS2010 wizard for new web application to create it. included a folder in the root directory and created new aspx pages to derive from the master page in the root directory of my site. everything shows on the new pages except the jpeg image logo in the master page. But other aspx pages i created in the root directory shows every thing fine.

View 1 Replies

Web Forms :: Master Pages - All My Pages Inherit From The Base Page Class

Jun 21, 2010

Currently I'm doing common functionality required throughout my site inside of my masterpage. What I want to do is move this functionality to a BaseClass so All my pages inherit from the Base Class. However, I'm not sure how to set this up interms of c# code with regards to Using a Base Class and then having a masterpage applied to my aspx pages that i create.

View 5 Replies

AJAX :: Set Title For Content Pages When Working With Master Pages?

May 17, 2013

How can we add titles to each content pages which inherits from mater pages in asp.net?

View 1 Replies

Web Forms :: Use Link Master Pages In Content Pages?

May 11, 2010

My requirement was to share master files among diff projects i read this doc [URL] so i use this technique to share msster pages among my diff projects in a soln but i dnt know how to reference such shared master page as if i use such

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../masterPages/masterInvGen.Master"

View 1 Replies

Combining CSS And JS In Master Pages And View Pages With SquishIt?

Jul 2, 2010

How do you implement SquishIt to bundle Css/Js across View Pages and Render it in the Master page? I thought I could use a ContentPlaceHolder above the Render portion, but there seems to be some odd behavior where it sometimes adds 3 files (1 in the view page and 2 in the master page) but other times will ignore the file added from the View Page.

Index.aspx
<asp:Content ContentPlaceHolderID="CssFiles" runat="server">
<% CssHelper.Add("home.css"); %>
</asp:Content>
Site.master
<asp:ContentPlaceHolder ID="CssFiles" runat="server" />
<% CssHelper.Add("reset.css"); %>
<% CssHelper.Add("master.css"); %>
<%=CssHelper.Render() %>

My current solution is a Static wrapper around SquishIt's static Bundle class that keeps the BundleBuilder in HttpContext.Current.Items.

I'm curious if this has been done successfully and how so.

View 2 Replies

Web Forms :: Changes In Master Page Does Not Apply To Nested Master Pages

Aug 4, 2010

I got a Master page and nested master pages in the subfolders.

Top Level Master page

Second Level Master page inherited Top Level Master page

Third Level Master page inherited Second Level Master page

However, changes (i.e. new images & alt. name) that I made in the Top level master page did not apply to the second or third levels.My webpage has a correct front page but not in the sections. How can i correct this ?

View 3 Replies

Difference Between Master Page And Master Pages In .Net?

Apr 1, 2011

what is difference between Master page and Master Pages in ASP.Net. Is both are same or different.

View 3 Replies

Visual Studio :: Debug A Multi Thread Program To See Local Variables Of Each Thread Using 2008

Jan 27, 2010

How can we debbug a multi-thread program to see local variables of each thread using visual studio 2008.

View 1 Replies

Architecture :: How Can Thread Update A Variable Shared With The Main Thread

Nov 24, 2010

I'm new to threading and have used it successfully, but limited. I can spawn a thread and have the main thread reference variables in the spawned thread, but I don't know how to allow the spawned thread to reference (and update) variables in the main thread.

Any example threading code I've seen on the web appears to be WAY more complicated than what I do, so I am unable to understand or integrate into my code.

Here is a quick example of how I use threading:

[code].....

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

Dynamic Page Changing / Redirect To Others Pages In Web Application?

May 18, 2010

I have web servie and web application ..Request hit from widows application to web service .if any request got means i need to redirect to some others pages in web application ,how can we do ..web application always open in server ..

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

Web Forms :: Changing User Control Properties In Aspx Pages?

Feb 25, 2011

I have a simple user control(.ascx) with a asp label inside of it. Using the codebehind(C#) from a aspx page, how can I change the text of that label? I have tried using public classes in my user control and a few other things that I could think of off the top of my head. Can somebody give me a quick example of how this would be done?

View 4 Replies

C# - Changing IDs With User Control And Master Page?

Oct 25, 2010

In my user control I got this inline CSS in which I have only css classes... like I am not setting any attribute or whatever on some ID..got only classes like :-

.sp
{
backgrond-image :url(blah blah);
}

and so on..

nothing of the sort

#id1
{
/* set some property here*/
}

Now my question:-

Do I need to worry about system generated IDs if the CSS in my user control got only classes ? like in my page source..the divs ID changes from their original ID to something like ctl00_ContentPlaceHolder2_ctl00_Banner_divBanner after adding usercontrol and master page ...

so changing IDs shouldn't make any difference..right ??

View 1 Replies

What Are The Differences Between Currently Executing .NET Thread And Win32 Thread

Mar 24, 2010

I am reading the Asp.net security documentation on msdn.I come across these tow terms and get really confused.

# WindowsIdentity = WindowsIdentity.GetCurrent()

which returns the identity of the security context of the currently executing Win32 thread.

# Thread = Thread.CurrentPrincipal

which returns the principal of the currently executing .NET thread which rides on top of the Win32 thread.

View 1 Replies

C# - Lock Thread.sleep Not Working With .NET Thread?

Jun 25, 2010

I have a password page and when someone enters an incorrect password I want to simply foil a brute force attack by having

bool isGoodPassword = (password == expected_password);

lock (this)
{
if (!isGoodPassword)
Thread.Sleep(2000);
}
I would expect that this would allow all correct passwords without stalling, but if one user enters a bad password another successful password from a different user would also be blocked. However, the lock doesn't seem to lock across ASP.NET threads.

View 4 Replies







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