CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 11/22/2007 12:22:26 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 12 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
Rob.TheBlackKni
Asp.Net User
How to refer to Header?11/22/2007 12:22:26 AM

0/0

Hi,

I am just experimenting with using Dynamic Data Pages on a new site I am building. Traditionally, I have set the Meta Description in my header in Page_Load by calling the following function:

Public Shared Sub SetMeta(ByRef Header As System.Web.UI.HtmlControls.HtmlHead, ByVal strName As String, ByVal strText As String)

Dim Meta As HtmlMeta = New HtmlMeta

For Each control As HtmlControl In Header.Controls

If control.TagName = "meta" Then

Meta = control

If Meta.Name = strName Then

Meta.Content = strText

End If

End If

Next

End Sub

 

When using Dynamic Data Pages, I get an error

Unable to cast object of type 'System.Web.UI.ResourceBasedLiteralControl' to type 'System.Web.UI.HtmlControls.HtmlControl'.

when I try to pass Header to the function.

In my Master Page, I have

<head runat="server">, so why does it think it is a literal?

 Thanks for any help!

Rob

srinathgnath
Asp.Net User
Re: How to refer to Header?11/22/2007 3:25:25 AM

0/0

HI there,

 

Please forward your code, so that i can help you....

 

 

Srinath 

Rob.TheBlackKni
Asp.Net User
Re: How to refer to Header?11/22/2007 3:53:25 AM

0/0

Ok, here is my MasterPage:

<%@ Master Language="VB" AutoEventWireup="true" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head runat="server">
 <title>PaxMondeo</title>
 <meta name="description" content="PaxMondeo VB.Net ASP.Net Web Site Development SQL Server Adelaide South Australia"/>
 
 <!--[if IE 5]>
 <style type="text/css">  
  .sidebarcontainer td, .sidebarcontainer tr {font-size:smaller;}  
  #subnav a {height:1em;}
     body td, body th {font-size:0.78em;}  
 </style>
 <![endif]-->
 <!--[if IE 7]>
 <style type="text/css">         
       #rightcolumn{margin-right: -152px;}
 </style>
 <![endif]-->
</head>
<body runat="server">
 <form id="headForm" method="get" action="http://www.google.com/search">
  <div id="headwrapper">
   <div id="header">
    <div id="logo">
    <asp:Image ID="logoImage" SkinID="logoImage" runat="server" />
    </div>
    <div id="banner">
                    <asp:Label ID="lblSlogan" runat="server" SkinID="slogan"  />
    </div>
    <div id="search" align=right>
                    <input type="text" name="q" size="15" maxlength="255" value="" style="border-right: #ff284e thin solid; border-top: #ff284e thin solid; font-size: 1em; border-left: #ff284e thin solid; border-bottom: #ff284e thin solid" />
                    <input type="submit" value="Google Search" style="border-right: #ffffff thin solid; border-top: #ffffff thin solid; font-size: 0.9em; border-left: #ffffff thin solid; border-bottom: #ffffff thin solid; background-color: #ff284e" /><br />
                    <input type="checkbox" name="sitesearch" value="paxmondeo.com" checked="checked" />
                    Search PaxMondeo<br />
    </div>
   </div>
  </div>
 </form>
 <form id="mainForm" runat="server">
  <div id="wrapper">
   <div id="mainnav">
    <asp:Menu  ID="menuMain" SkinID="mainmenu" runat="server" Orientation="Horizontal" />   
   </div>
   <div id="contentwrapper">
    <div id="floatwrapper">
     <div id="centercolumn">
      <div id="breadcrumbs">
       <asp:SiteMapPath runat="server" ID="smPath" />
      </div>
      <div id="copy">
       <asp:ContentPlaceHolder runat="server" ID="mainCopy">
        <%-- Main content goes here
        --%>
       </asp:ContentPlaceHolder>
      </div>
     </div>
     <div id="leftcolumn">
      <div id="leftcolcontainer">
       <div id="subnav"> 
        <asp:SiteMapDataSource runat="server" ID="subnavSitemap" StartingNodeOffset="1" StartFromCurrentNode="false" ShowStartingNode="false" />       
        <asp:Menu runat="server" ID="subMenu" SkinID="subMenu" DataSourceID="subnavSitemap" />
       </div>
       <asp:ContentPlaceHolder ID="leftColumn" runat="server">
        <%-- Left sidebar content placeholder. Again the
        individual boxes are created by using a <div> and
        assigning a class to it: 'sidebarcontainer'.
        Follow the structure of the sample content below:
        
        <div class="sidebarcontainer">
         <h4>Headline</h4>
         <p>Content</p>
        </div>        
        --%>
        <div class="sidebarcontainer">
        </div>
        <div class="sidebarcontainer">
         <h4>
          Quick Links</h4>
         <ul>
          <li><a href="Contact.aspx" title="Contact Us">&raquo; Contact Us</a></li>
         </ul>
         <br />
        </div>
        <div class="sidebarcontainer">
         <asp:Login ID="Login1" runat="server" Width="120px">       
          <LayoutTemplate>
           <h4>Log In</h4>
           <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"><u>U</u>ser Name:</asp:Label><br />
           <asp:TextBox ID="UserName" runat="server" AccessKey="u" TabIndex="60" Columns="15" />
           <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
            ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator><br />
           <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"><u>P</u>assword:</asp:Label><br />
           <asp:TextBox ID="Password" runat="server" TextMode="Password" Columns="15" AccessKey="p" TabIndex="61" />
           <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
            ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator><br />
           <asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." TabIndex="62" AccessKey="r" /><br />
           <span style="color: red">
            <asp:Literal ID="FailureText" runat="server" EnableViewState="False" />
           </span>
           <div align="right"><asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" AccessKey="l" TabIndex="63" ValidationGroup="Login1"  />
           </div>
          </LayoutTemplate>
         </asp:Login>         
        </div>
       </asp:ContentPlaceHolder>
      </div>
     </div>
    </div>
    <div id="rightcolumn">
     <div id="rightcolcontainer">
      <asp:ContentPlaceHolder ID="rightColumn" runat="server">
       <%-- Right sidebar content placeholder. Again the
        individual boxes are created by using a <div> and
        assigning a class to it: 'sidebarcontainer'.
        Follow the structure of the sample content below:
        
        <div class="sidebarcontainer">
         <h4>Headline</h4>
         <p>Content</p>
        </div>        
        --%>
       <div class="sidebarcontainer">
                                    <asp:Repeater ID="rptrBlog" runat="server">
                                        <HeaderTemplate>
                    <h4>
                                                Blog</h4>
                                       </HeaderTemplate>
                                       <ItemTemplate>
                                          <h5>
                                            <asp:label runat="server" ID="lblBlogTitle" Text='<%# DataBinder.Eval(Container.DataItem, "BlogTitle") %>' />
                                            <asp:label runat="server" ID="lblBlogDate" Text='<%# DataBinder.Eval(Container.DataItem, "BDate") %>' />
                                          </h5>
                                          <p>
                                            <asp:label runat="server" ID="lblBlogText" SkinID="BlogText"  Text='<%# DataBinder.Eval(Container.DataItem, "BText") %>' />
                                          </p>
                    <div class="readmore"><a href='Blog.aspx?item=<%# DataBinder.Eval(Container.DataItem, "BlogTitle") %>' title="More info">&raquo; more</a></div>
                                         
                                       </ItemTemplate>
                                        <FooterTemplate>
                                       </FooterTemplate>
                                   </asp:Repeater>
       </div>
      </asp:ContentPlaceHolder>
     </div>
    </div>
    <div class="footer">
     &copy; Copyright 2007 PaxMondeo.
    </div>
    <div class="PaxMondeo">
     Web Site Created by <a href="http://www.PaxMondeo.com" title="PaxMondeo">PaxMondeo</a>, Adelaide, South Australia
    </div>
   </div>
  </div>
 </form>
</body>
</html>

 Here, for example is a stripped down Default.aspx.vb

Imports System.Net.Dns
Imports System.Reflection.MethodBase

Partial Class _Default
    Inherits Microsoft.Web.DynamicDataControls.DynamicDataPage

    <System.Web.Services.WebMethod()> <System.Web.Script.Services.ScriptMethod()> Public Shared Function GetSlides() As AjaxControlToolkit.Slide()
        Return New AjaxControlToolkit.Slide() {New AjaxControlToolkit.Slide("images/World.bmp", "World", "World"), New AjaxControlToolkit.Slide("images/World.bmp", "World", "World"), New AjaxControlToolkit.Slide("images/World.bmp", "World", "World"), New AjaxControlToolkit.Slide("images/World.bmp", "World", "World"), New AjaxControlToolkit.Slide("images/World.bmp", "World", "World"), New AjaxControlToolkit.Slide("images/Australia.bmp", "Australia", "Australia"), New AjaxControlToolkit.Slide("images/SA.bmp", "SA", "SA"), New AjaxControlToolkit.Slide("images/Part SA.bmp", "Part SA", "Part SA"), New AjaxControlToolkit.Slide("images/Gt Adelaide.bmp", "Gt Adelaide", "Gt Adelaide"), New AjaxControlToolkit.Slide("images/Adelaide.bmp", "Adelaide", "Adelaide"), New AjaxControlToolkit.Slide("images/Adelaide.bmp", "Adelaide", "Adelaide"), New AjaxControlToolkit.Slide("images/Adelaide.bmp", "Adelaide", "Adelaide"), New AjaxControlToolkit.Slide("images/Adelaide.bmp", "Adelaide", "Adelaide"), New AjaxControlToolkit.Slide("images/Adelaide.bmp", "Adelaide", "Adelaide")}
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim strHost As String

        Try
            If Not IsPostBack Then

                Utilities.SetMeta(Header, "description", "PaxMondeo Web ASP.Net VB.Net SQL Server Development Adelaide South Australia")
            End If

        Catch ex As Exception
            Utilities.SendMessage("[email protected]", "Error in PaxMondeo Web Site", "Error " & ex.ToString & " in " & GetCurrentMethod.Name)
        End Try
    End Sub
End Class

And as mentionedbefore, here is SetMeta:

    Public Shared Sub SetMeta(ByRef Header As System.Web.UI.HtmlControls.HtmlHead, ByVal strName As String, ByVal strText As String)

        Dim Meta As HtmlMeta = New HtmlMeta
        For Each control As HtmlControl In Header.Controls
            If control.TagName = "meta" Then
                Meta = control
                If Meta.Name = strName Then
                    Meta.Content = strText
                End If
            End If
        Next
    End Sub

Kind regards,

 

Rob

srinathgnath
Asp.Net User
Re: How to refer to Header?11/22/2007 4:22:50 AM

0/0

Hi there,

Try this out ..

 

Public Shared Sub SetMeta(ByRef Header As System.Web.UI.HtmlControls.HtmlHead, ByVal strName As String, ByVal strText As String)    

Dim Meta As HtmlMeta
        For i as Integer=0 to Header.Controls.Count next
            If TypeOf (Header.Controls(0)) Is HtmlMeta Then
                Meta = Header.Controls(0)
                If Meta.Name = strName Then
                    Meta.Content = strText
                End If
            End If
        Next

    End Sub

 

 

 Srinath

Dont forget to click "Mark as Answer" on the post that helped you.
It marks your thread as Resolved so we will all know you have been helped.

 

 

Rob.TheBlackKni
Asp.Net User
Re: How to refer to Header?11/22/2007 4:33:46 AM

0/0

Hi Srinath

 The problem is that in the Page_Load, there is an error that it can't cast the Header to type System.Web.UI.HtmlControls.HtmlHead, which I assume is because I am using Dynamic Data Pages rather than System.Web.UI pages.

 

Cheers

 

Rob

Rob.TheBlackKni
Asp.Net User
Re: How to refer to Header?11/22/2007 4:42:06 AM

0/0

Hi,

What may be causing confusion here is that I tried to post this question in the ASP.Net Futures forum, as this question specificaly relates to Dynamic Data Pages, but for some reason the moderator moved it here.

 My code works OK in a normal ASP.Net Page. It doesn't work on an AJAX page.

 

So, my question is how do I refer to the header on a Master page from the codebehind on an AJAX Dynamic Data Page?

 Thanks

 

Rob

srinathgnath
Asp.Net User
Re: How to refer to Header?11/22/2007 5:05:23 AM

0/0

 Hi there,

 The page is using ASp.Net AJAX and its working quite well.....

 See the code :

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
 <meta name="description" content="PaxMondeo VB.Net ASP.Net Web Site Development SQL Server Adelaide South Australia"/>
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
    <div>
      <asp:Button ID="Button1" runat="server" Text="Button" />
    </div> </ContentTemplate></asp:UpdatePanel>
    </form>
</body>
</html>

 

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
     Dim Meta As HtmlMeta
        For i As Integer = 0 To Header.Controls.Count - 1
            If TypeOf (Header.Controls(i)) Is HtmlMeta Then
                Meta = Header.Controls(i)
                If Meta.Name = "description" Then
                    Meta.Content = "srinath"
                End If
            End If
        Next

    End Sub

End Class 

 

 

Srinath 

Rob.TheBlackKni
Asp.Net User
Re: How to refer to Header?11/22/2007 5:25:07 AM

0/0

Hi Srinath

 That is because you have changed it to a System.eb.UI.Page

To use the AJAX futures components (unless I have misunderstood something, somewhere), it has to be a Microsoft.Web.DynamicDataControls.DynamicDataPage

i.e.

Partial Class _Default
    Inherits Microsoft.Web.DynamicDataControls.DynamicDataPage

and not

Partial Class _Default
    Inherits System.Web.UI.Page

 Yes, this function works if I change back to System.Web.UI.Page, but then the page crashes because itis not compatible with the AJAX/Futures components in the .ASPX page

Kind regards,

 

Rob

8 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
SIP: Understanding the Session Initiation Protocol Authors: Alan B. Johnston, Pages: 283, Published: 2003
Voice Over IP Fundamentals Authors: Jonathan Davidson, James Peters, Manoj Bhatia, Satish Kalidindi, Sudipto Mukherjee, Pages: 394, Published: 2006
Carrier Grade Voice Over IP Authors: Daniel Collins, Pages: 522, Published: 2002
Principles and Methods of Law and Economics: Basic Tools for Normative Reasoning Authors: Nicholas Leonidas Georgakopoulos, Pages: 378, Published: 2005
SIP Demystified Authors: Gonzalo Camarillo, Pages: 320, Published: 2002
Web Technologies: A Computer Science Perspective Authors: Jeffrey C. Jackson, Pages: 574, Published: 2007
Programming Languages and Systems: 16th European Symposium on Programming, ESOP 2007, Held as Part of the Joint European Conferences on Theory and Practics [i.e. Practice] of Software, ETAPS 2007, Braga, Portugal, March 24-April 1, 2007 : Proceedings Authors: Portugal European Symposium on Programming 16th Braga, Rocco De Nicola, European Conferences on Theory, Pages: 538, Published: 2007
Hardware Verification with SystemVerilog: An Object-oriented Framework Authors: Mike Mintz, Robert Ekendahl, SpringerLink (Online service, Inc NetLibrary, Pages: 314, Published: 2007
Beginning PHP and Oracle: From Novice to Professional Authors: W. Jason Gilmore, Bob Bryla, Pages: 763, Published: 2007

Web:
How to refer to Header on Dynamic Data Page? - ASP.NET Forums How to refer to Header on Dynamic Data Page? Last post 11-27-2007 3:46 PM by dzhu2005. 3 replies. Sort Posts: ...
sip: Refer-To Header A static sip_refer_to_t structure for Refer-To header must be initialized with the SIP_REFER_TO_INIT() macro. For instance, ...
Re: isfocus in Refer-to header: msg#00029 Removed inclusion of "isfocus" parameter in Refer-To header field - this may be a useful extension to the REFER mechanism in the future, however. ...
[Sip] Refer-To header/RFC3261 ambiguity? for the Refer-To header. Our guess, therefore, is that RFC 3515 should have the same words for the Refer-To header as RFC 3261 has for ...
How to refer to Header on Dynamic Data Page? - ASP.NET Forums How to refer to Header on Dynamic Data Page? Last post 11-27-2007 3:46 PM by dzhu2005. 3 replies. Sort Posts:. Oldest to newest, Newest to oldest ...
[Sip-implementors] URI syntax in Refer-To header So this rule applies anywhere the ambiguity exists, including the Refer-To header. Paul Dmitry Akindinov wrote: > Hello, > > RFC 3261 imposes the following ...
sip: Refer-Sub Header Note that sip_t does not contain sip_refer_sub field, but sip_refer_sub() accessor function should be used for accessing Refer-Sub header structure. ...
HTTP/1.1: Header Field Definitions This section defines the syntax and semantics of all standard HTTP/1.1 header fields. For entity-header fields, both sender and recipient refer to either ...
[Sip] Refer-To header and Replaces option Is the usage of Replaces parameter in a Refer-To header a standard usage. If. it it could you please point me to the RFC that specifies the usage. ...
RE: method parameter in REFER-TO header: msg#00118 hi Suheel, UA sends REFER request. The parameter in REFER-TO header field is specified as SUBSCRIBE. UA which receives REFER request doesn't ...

Videos:
G1 Headmasters"Head On, Fortress Maximus"[Part 1] Transformers The Headmasters Generation 1 Episode#13 "Head On, Fortress Maximus" Takara 1987 info You should know: -The Japanese refer to Prime as ...
Kevin Annett Visits Toronto Church Head Offices Kevin Annett Visits Toronto Church Head Offices to bring forth "Justice" to those children who never returned home. This refers to the most recent re...
G1 Headmasters"Head On, Fortress Maximus"[Part 2] Transformers The Headmasters Generation 1 Episode#13 "Head On, Fortress Maximus" Takara 1987 info You should know: -The Japanese refer to Prime as ...
Talking With Jon - Episode 2 Clip - Mr. Potato Head 500 Miles Talking With Jon - Episode 2 Clip - Mr. Potato Head 500 Miles The potato (plural form: potatoes) (Solanum tuberosum) is a perennial plant of the Sol...
The Headhunters top 15 Head kicks in MMA Visit www.worldofcombat.net for mma related stuff. My list of the 15 greatest head kicks in MMA. Now I probably missed out on some great ones, but h...
breakfast with the head Breakfast with the head, 11’34’’, 2003. Extract: 00:01:13 /Color /with sound /on monitor or screen (The video shows contrast of moving images betwe...
mj talks to Libba Bray mj talks to New York Times bestselling author Libba Bray about her new book The Sweet Far Thing. Also, unicorns, the ugly side of writing, YA audienc...
Fleetwood Mac in the studio + Over my head Live Going home special - Rosebud Christine McVie has told interviewers many times that her songs are not really about anyone, they're just love songs. ...
Talking With Jon - Episode 17 Clip - Life as the pope Talking With Jon - Episode 17 Clip - Life as the pope The Pope (from Greek: pappas, father; from Latin: papa, Papa, father1) is the head of the Cath...
PS3: How to Create & Transfer AVC - H.264 files for the PS3 The PS3 has great Media Center capabilities but is quite picky about the header information for the files it will accept. The encode may be OK but t...




Search This Site:










redirect from one tab to another tab

using my own type in profile properties

pages not found after fresh install on new web server

can't find "installation folder" dialog in web setup project

getting additonal informatin into the membershipprovider

how do i start the starters kit??

web part with listbox textbox and button

dnn 3.0.11 & date formats

help - skin - [solpartmenu]

server error in '/' application.

cannot get this alert working on ascx control

pc configuration for visual studio .net and sql server

restricting users

duplicate names for controls

filling the 'ajax' tool box

installing vs 2008 beta 2 - how?

when an anonymous user is accessing any thread->runtime error

sowens technologies announces new line of security software for dotnetnuke portal software

deny access to a specific folder

html text in <asp:textbox> control

how do i make links to documents more secure?

how can i connect my custom module to two or more sql databases at the same time

use sitemap to display nav items

treeview: msdn style - load on demand

dnn on pc and mac, browsers

where is master.page.header.metadata?

sql server 2005 integrated security question

free rss content available?

new module backupscript by evotiva (formely gruposur)

how to access controls in a placeholder

 
All Times Are GMT