.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Master-Content Rendering Confusion

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :ASP.Net

Here is my scenario. In my Master file, the head section, i register my scripts including jquery. After this, I have a content section for child pages to register anything additional into the head. Simple enough.

In one of my pages, I am using the SimpleModal JQuery plugin, so in his head content section, i register the plugin. When the page runs, i get an error the member does not exist when I call one of the methods from the plugin, so its acting like jquery is not loaded. BUT, if I add a blank <script> tag right before I register the jquery plugin, it works. 

Any ideas? Am I registering them in the wrong order? What is the right order everything renders??


View Complete Post

More Related Resource Links

Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Rendering User Control content


I have a scenario where, the content is:
 ASP.NET Controls
      User Control
 ASP.NET Controls

The entire div code is rendered and is sent at a mail using the code:

Dim sw As New StringWriter()
Dim w As New HtmlTextWriter(sw)
Dim s As String = sw.GetStringBuilder().ToString()

This works fine except that the User Control does not get rendered.

Any way out, so that the User Control content is also rendered ?

Request.PathInfo losing Master Page content and CSS link


Hi All-


I'm using Request.PathInfo to response.redirect as user to a different page ( based on the content after .aspx ).  It redirect just fine however, once redirected, the page loses all content from the master page and the CSS link.  I've searched and can't find an answer. 

Does anyone have a solution for this?

Change label text on master page from the content page.

Hello. Can I access the objects (for example change the label text) on the master page, from its contents page code? If yes, how can I approach that? Thank you Artashes

bind drop down list in content page from value from master page

Hi all, I have applied nested master page to some page. Now i want to bind drop downlist from value selected in dropdown list in master page of master applied to that page. the hierarchy of pages is  mypage.aspx -> main.aspx -> inner.master I want bind dropdown list in  mypage.aspx from  from value selected in dropdown list in  inner.master Please help me. 

master pages - how to access content page from master page?

Hello,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?

Accessing master page from content page? Raising Event?

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?Thanks in advancesb

Problems with Master Page and content window

I have a master page whose primary function is to allow a user to search for a Credit Union.  They can either search by ID # or search by name.  With processing this page it will set session variables which in turn I would hope would be passed along to the content window. Within the content window I am displaying the information that will be needed on that particutlar page, if no record is found then it will allow them to add.  I also need it to clear the fields in the content window if they go from one record with data to one without.  Now if a user types in the ID#, then it doesn't seem to have any problems populating the content window.  The problem comes when they try and search by name.  If more then one record is returned then it will populate a listbox.  Which then I would like a user to select the name they are searching for and then populate the search boxes as well as process the content window. The problem I seem to be facing is the Page Load on the content window.  Session variables don't seem to be set in time for the content window to have the variable available to it. Hopefully you can help me out.Masterpage.master.vb Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'ResetValues() Me._txtCUName.Attributes.Add("onchange", "if(document

Accessing master page controls from content page formview



I have a master page with a textbox that I want to use for a search, and display the results on the content page.

I've dragged in the datasource to the content page, and configured the formview to use that datasource... almost.

The issue I'm having is that on the last step of the configure datasource wizard where you select the parameters, I want to select the master page textbox control for the search parameter... but of course it's not available in the list. The list only allows me to choose controls from the content page.

How do I set this master page search box as the parameter for my datasource?

Any ideas would be much appreciated!



help me on master pages & content place holders.


Hello sir, i am new to this forum, so please excuse me on my mistakes. I have a master page with asp TextBox and a Button also with 2 ContentPlaceHolders(ContentPlaceHolders1 & ContentPlaceHolders2). The project contains 2 WebForms Default.aspx & Search.asp. The purpose is to use the button click event to search records & place the results in the content page Search.aspx in ContentPlaceHolders1. The search is working fine but the problem is that the results get placed on the top(instead in the ContentPlaceHolders1) with the master page controls going down on the Search.aspx page. Please help me on this. I tried a lots of things like changing search page events to Page_LoadComplete etc etc but nothing worked.

My Default.aspx.vb code is as:

    Public Sub mySearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mySearch.Click

        Response.Redirect("Search.aspx?nameA=" + Keyword.Text)

    End Sub

End Class

My Search.aspx page is:

Manage Content on a Master Page from a Central Location?


Phew long title! But what is the best way to manage and render content on a master page that you want to show up on ever single site/subsite? For example I have a bunch of site collections with footer links. Each site collection however will have its own sets of links but we don't want them hard coded into the master page - so we don't have to manage 80 different master pages.

Right now I am using an XML file in the style library which is called from the master page. This works alright, but if that file gets deleted or something then the whole site breaks because it can't find that file. Additionally, the XML file is finicky with some of the stuff you put in it.

Any better suggestions?

CollapsiblePanelExtender Onload when using Master/Content Pages



I'm wondering if anyone else has run into this problem; I have a collapsible panel extender to which I need to add some event handlers via javascript on page load: 


This was working perfectly...*until* I split the page into the Master/Content page scenario.  The control, the scriptmanager and the javascript are all declared in the content page right now. 

Suddenly, all my client side code comes up as the object being null or not found at the window.onload event.  After 3 days of chasing this dragon, I added a test button which calls the same functionality which should run onload and when clicked, it has no trouble at all finding the object *after* the page has fully loaded.  I've looked into almost all the posts on the web about this and I've found the question...but not the answer.  I've played with the recommended fixes dealing with BehaviorID...the ClientID...the ctl100_control_object and ctl100$control$object names and I'm still dead in the water.

Somehow, I have to get this code to run at the page onLoad event.  I'm gratefull for any suggestions at this point!

Thanks in advance!

Css with master and content pages - Problem


I have  a master page website with lots of content pages. On my master page  i  have a conditional css choice <!--[if IE]>
    <link rel="stylesheet" type="text/css" href="iespecific.css" />

Works great on master page ;-) However it doesnt not recognise it on the content pages which is causing mea problem as I need different css for ie and firefox  the whole way through my website not just on the first page. Or any pages which are not content pages of master. I have even tried  to putthe same code to choosea stylesheet in the content placeholder head section of the content page no luck... If anyone could help i would be so grateful i have come to a dead end

Image background color is showing while i drag in content place holder in master page ???


Hi  ...

I had few icons and images in my old web project which had no issue with the images and icons background color.

Now i have changed the total look and layout of my web site. After doing so , my old images and icons as well as new images and icons backgroud color is also displaying in the image.

The same image is looking good in my old web site layout ...

I tried all the stuff to show only image not image background ... But , it is not happening ....

The main thing is the same images and icons background color is not showing in my old design ...

Look at the image background , it has grey color background. It was not happening in my old web site design

Plz help me to solve this .... 

Finding control from master page inside tabcontainer in content page


I have a codebehind.vb for a master page from which I'm trying to find a hiddenfield in the content page. I was finding it like this without a hitch...

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("hfSearch"), HiddenField)

Then I decided to add an Ajax TabContainer to the content page. Now I'm having a hard time finding the hiddenfield. I've tried these variations, but still not working.

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("TabContainer1").FindControl("TabPanel1").FindControl("hfSearch"), HiddenField)

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("TabContainer1").FindControl("hfSearch"), HiddenField)

Dim hfContentSearch As HiddenField = CType(Page.Master.FindControl("main").FindControl("TabPanel1").FindControl("hfSearch"), HiddenField)

Can someone please help me with the syntax?

Thank you.


Content quarry not rendering


My content quary webpart is rendering some html tags for out put. i have quary list item content news annoucement list but when rendering it have following type unwanted Div tags

Expolanka Achievements at NCE Awards, 2009
<div class="ExternalClass7E484B9B42BF4C85BAC54B1A733E34EC"><p>The National Chamber of Exporters of Sri Lanka (NCE) honoured three of the line companies of Expolanka Group for their exceptional performance, service quality and responsible corporate conduct in the arena of product export?</p></div>

Above display some of the output please how to remove this ???


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend