How to set the div Height & Width from within C#

Discussion in 'ASP .Net' started by Anton, Aug 23, 2009.

  1. Anton

    Anton Guest

    Hi

    asp.net 3.5

    I have this markup, The problem is that I want the border to go arround the
    image. As the markup is now thediv fills entire space and the border comes
    on the outside of that space.. I want the border to go arround the image so
    I can show to the user how size of the image.

    In the code I can get the pixels size of the image so I was wondering how to
    set the div height & width programmatically?
    I didn't see any height & width properites on the div

    (I know I have to add a runat tag and an id in order to reference it from
    servre code)

    <div style="text-align:center; border:solid 2px #3399FF; margin-left:auto;
    margin-right:auto;" > <%--#3399FF--%>
    <asp:Image ID="imgPreview" runat="server" ImageUrl="~/Preview.aspx"
    />
    </div>

    any ideas?
     
    Anton, Aug 23, 2009
    #1
    1. Advertising

  2. Anton

    Anton Guest

    I've soled it using
    divPreview.Attributes["style"]

    "Anton" <no_email> wrote in message
    news:eOh$...
    > Hi
    >
    > asp.net 3.5
    >
    > I have this markup, The problem is that I want the border to go arround
    > the image. As the markup is now thediv fills entire space and the border
    > comes on the outside of that space.. I want the border to go arround the
    > image so I can show to the user how size of the image.
    >
    > In the code I can get the pixels size of the image so I was wondering how
    > to set the div height & width programmatically?
    > I didn't see any height & width properites on the div
    >
    > (I know I have to add a runat tag and an id in order to reference it from
    > servre code)
    >
    > <div style="text-align:center; border:solid 2px #3399FF; margin-left:auto;
    > margin-right:auto;" > <%--#3399FF--%>
    > <asp:Image ID="imgPreview" runat="server" ImageUrl="~/Preview.aspx"
    > />
    > </div>
    >
    > any ideas?
    >
     
    Anton, Aug 23, 2009
    #2
    1. Advertising

  3. On Aug 23, 11:38 am, "Anton" <no_email> wrote:
    > I've soled it using
    > divPreview.Attributes["style"]
    >
    > "Anton" <no_email> wrote in message
    >
    > news:eOh$...
    >
    >
    >
    > > Hi

    >
    > > asp.net 3.5

    >
    > > I have this markup, The problem is that I want the border to go arround
    > > the image. As the markup is now thediv fills entire space and the border
    > > comes on the outside of that space..  I want the border to go arround the
    > > image so I can show to the user how size of the image.

    >
    > > In the code I can get the pixels size of the image so I was wondering how
    > > to set the div height & width programmatically?
    > > I didn't see any height & width properites on the div

    >
    > > (I know I have to add a runat tag and an id in order to reference it from
    > > servre code)

    >
    > > <div style="text-align:center; border:solid 2px #3399FF; margin-left:auto;
    > > margin-right:auto;" >  <%--#3399FF--%>
    > >        <asp:Image ID="imgPreview" runat="server" ImageUrl="~/Preview.aspx"
    > > />
    > > </div>

    >
    > > any ideas?- Hide quoted text -

    >
    > - Show quoted text -


    I think you can also try to use CSS (padding and border attributes)
    without using any "fixed" values from the code-behind
     
    Alexey Smirnov, Aug 26, 2009
    #3
    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. Steve Richter
    Replies:
    2
    Views:
    7,979
    Steve Richter
    Jun 15, 2007
  2. Bernd Meier
    Replies:
    6
    Views:
    535
    GTalbot
    Jan 14, 2008
  3. muggslab

    Div Height = Image height. help

    muggslab, Feb 1, 2010, in forum: HTML and CSS
    Replies:
    1
    Views:
    884
    muggslab
    Feb 1, 2010
  4. Don Vaillancourt

    How to tell height of div where height is not set?

    Don Vaillancourt, Jan 28, 2005, in forum: Javascript
    Replies:
    8
    Views:
    164
    Dietmar Meier
    Jan 31, 2005
  5. Replies:
    0
    Views:
    134
Loading...

Share This Page