Visual Studio problem with BODY tag

Discussion in 'ASP .Net' started by Alan No Spam, Nov 23, 2004.

  1. Alan No Spam

    Alan No Spam Guest

    I am using Visual Studio 2003 and in order not to repeat body tag details in
    every page

    <body leftmargin=0 topmargin=0 ....

    I put those details as an variable in my class:

    public class WebRoot: System.Web.UI.Page {
    public String my_body = "leftmargin=0 topmargin=0";
    ......
    }

    and then use the following in the default.aspx page:

    <body MS_POSITIONING="GridLayout" <%=my_body%>>

    Now, the problem is I cannot use "DESIGN" mode anymore, VS2003 gives me
    error saying "Could not open in Design View. Please quote around a '<%%>'
    block used as an attribute value or within a <SELECT> element.

    However, if I put <%=my_body%> in other places in the aspx page, it works.
    Only <Body> tag is the problem.. help!!!

    Any solutions?
    Alan No Spam, Nov 23, 2004
    #1
    1. Advertising

  2. Alan No Spam

    Mark Guest

    Just an idea, you could set this information via the codebehind page..

    e.g in the aspx page

    <body id="BodyTag" runat="server" etc

    Then from the codebehind page (.cs) go something like this;

    BodyTag.attributes.add["leftmargin","0"];
    BodyTag.attributes.add["topmargin","0"];

    This way you will achieve the same result but be able to view the page in
    design mode...

    hth
    Cheers
    Mark
    --
    ----------------------------------------------------------------
    -**-
    www.myoddjobs.co.nz :- Job auction website
    -**-
    Replace the Z with the e to reply
    ----------------------------------------------------------------

    "Alan No Spam" <> wrote in message
    news:...
    > I am using Visual Studio 2003 and in order not to repeat body tag details

    in
    > every page
    >
    > <body leftmargin=0 topmargin=0 ....
    >
    > I put those details as an variable in my class:
    >
    > public class WebRoot: System.Web.UI.Page {
    > public String my_body = "leftmargin=0 topmargin=0";
    > .....
    > }
    >
    > and then use the following in the default.aspx page:
    >
    > <body MS_POSITIONING="GridLayout" <%=my_body%>>
    >
    > Now, the problem is I cannot use "DESIGN" mode anymore, VS2003 gives me
    > error saying "Could not open in Design View. Please quote around a '<%%>'
    > block used as an attribute value or within a <SELECT> element.
    >
    > However, if I put <%=my_body%> in other places in the aspx page, it works.
    > Only <Body> tag is the problem.. help!!!
    >
    > Any solutions?
    >
    >
    >
    Mark, Nov 24, 2004
    #2
    1. Advertising

  3. Thanks a lot your idea works!!!!!!!! For other people future reference, the
    valid C# code should be:

    - In ASPX page:
    <body runat="server" id="BodyTag" MS_POSITIONING="GridLayout">

    - In ASPX.CS page:
    protected System.Web.UI.HtmlControls.HtmlGenericControl BodyTag;
    BodyTag.Attributes.Add("leftmargin","0");
    BodyTag.Attributes.Add("topmargin","0");

    Regards,

    C.P.
    [No MCSD, No Certification]


    "Mark" <> wrote in message
    news:co0i2j$cdg$...
    > Just an idea, you could set this information via the codebehind page..
    >
    > e.g in the aspx page
    >
    > <body id="BodyTag" runat="server" etc
    >
    > Then from the codebehind page (.cs) go something like this;
    >
    > BodyTag.attributes.add["leftmargin","0"];
    > BodyTag.attributes.add["topmargin","0"];
    >
    > This way you will achieve the same result but be able to view the page in
    > design mode...
    >
    > hth
    > Cheers
    > Mark
    > --
    > ----------------------------------------------------------------
    > -**-
    > www.myoddjobs.co.nz :- Job auction website
    > -**-
    > Replace the Z with the e to reply
    > ----------------------------------------------------------------
    >
    > "Alan No Spam" <> wrote in message
    > news:...
    > > I am using Visual Studio 2003 and in order not to repeat body tag

    details
    > in
    > > every page
    > >
    > > <body leftmargin=0 topmargin=0 ....
    > >
    > > I put those details as an variable in my class:
    > >
    > > public class WebRoot: System.Web.UI.Page {
    > > public String my_body = "leftmargin=0 topmargin=0";
    > > .....
    > > }
    > >
    > > and then use the following in the default.aspx page:
    > >
    > > <body MS_POSITIONING="GridLayout" <%=my_body%>>
    > >
    > > Now, the problem is I cannot use "DESIGN" mode anymore, VS2003 gives me
    > > error saying "Could not open in Design View. Please quote around a

    '<%%>'
    > > block used as an attribute value or within a <SELECT> element.
    > >
    > > However, if I put <%=my_body%> in other places in the aspx page, it

    works.
    > > Only <Body> tag is the problem.. help!!!
    > >
    > > Any solutions?
    > >
    > >
    > >

    >
    >
    ChInKPoInt [No MCSD], Nov 24, 2004
    #3
  4. Alan No Spam

    Mark Guest

    Your welcome :)
    --
    ----------------------------------------------------------------
    -**-
    www.myoddjobs.co.nz :- Job auction website
    -**-
    Replace the Z with the e to reply
    ----------------------------------------------------------------

    "ChInKPoInt [No MCSD]" <> wrote in message
    news:...
    > Thanks a lot your idea works!!!!!!!! For other people future reference,

    the
    > valid C# code should be:
    >
    > - In ASPX page:
    > <body runat="server" id="BodyTag" MS_POSITIONING="GridLayout">
    >
    > - In ASPX.CS page:
    > protected System.Web.UI.HtmlControls.HtmlGenericControl BodyTag;
    > BodyTag.Attributes.Add("leftmargin","0");
    > BodyTag.Attributes.Add("topmargin","0");
    >
    > Regards,
    >
    > C.P.
    > [No MCSD, No Certification]
    >
    >
    > "Mark" <> wrote in message
    > news:co0i2j$cdg$...
    > > Just an idea, you could set this information via the codebehind page..
    > >
    > > e.g in the aspx page
    > >
    > > <body id="BodyTag" runat="server" etc
    > >
    > > Then from the codebehind page (.cs) go something like this;
    > >
    > > BodyTag.attributes.add["leftmargin","0"];
    > > BodyTag.attributes.add["topmargin","0"];
    > >
    > > This way you will achieve the same result but be able to view the page

    in
    > > design mode...
    > >
    > > hth
    > > Cheers
    > > Mark
    > > --
    > > ----------------------------------------------------------------
    > > -**-
    > > www.myoddjobs.co.nz :- Job auction website
    > > -**-
    > > Replace the Z with the e to reply
    > > ----------------------------------------------------------------
    > >
    > > "Alan No Spam" <> wrote in message
    > > news:...
    > > > I am using Visual Studio 2003 and in order not to repeat body tag

    > details
    > > in
    > > > every page
    > > >
    > > > <body leftmargin=0 topmargin=0 ....
    > > >
    > > > I put those details as an variable in my class:
    > > >
    > > > public class WebRoot: System.Web.UI.Page {
    > > > public String my_body = "leftmargin=0 topmargin=0";
    > > > .....
    > > > }
    > > >
    > > > and then use the following in the default.aspx page:
    > > >
    > > > <body MS_POSITIONING="GridLayout" <%=my_body%>>
    > > >
    > > > Now, the problem is I cannot use "DESIGN" mode anymore, VS2003 gives

    me
    > > > error saying "Could not open in Design View. Please quote around a

    > '<%%>'
    > > > block used as an attribute value or within a <SELECT> element.
    > > >
    > > > However, if I put <%=my_body%> in other places in the aspx page, it

    > works.
    > > > Only <Body> tag is the problem.. help!!!
    > > >
    > > > Any solutions?
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Mark, Nov 24, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh
    Replies:
    2
    Views:
    494
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  2. shruds
    Replies:
    1
    Views:
    757
    John C. Bollinger
    Jan 27, 2006
  3. Thirumalai
    Replies:
    0
    Views:
    631
    Thirumalai
    May 22, 2006
  4. rockdale
    Replies:
    1
    Views:
    587
    Juan T. Llibre
    Aug 23, 2006
  5. xman
    Replies:
    0
    Views:
    464
Loading...

Share This Page