Retrieve a Panel's style attributes

Discussion in 'ASP .Net' started by John Spiegel, Feb 6, 2004.

  1. John Spiegel

    John Spiegel Guest

    Hi all,

    How can I read through the style attributes for a server control? It would
    be so convenient if one could reference an index, something like:
    pnlPageHeader.Style.Keys["Top"].ToString();

    TIA,

    John
    John Spiegel, Feb 6, 2004
    #1
    1. Advertising

  2. Well, you can get an enumerator on Keys and iterate through. This sample is
    from MSDN:

    <html>
    <script language="C#" runat="server">
    void Page_Load(Object Src, EventArgs e) {
    Message.InnerHtml += "<h5>The Text Box's CssStyleCollection
    contains:</h5>";

    IEnumerator keys = MyText.Style.Keys.GetEnumerator();

    while (keys.MoveNext()) {

    String key = (String)keys.Current;
    Message.InnerHtml += key + "=" + MyText.Style[key] + "<br>";
    }
    }
    </script>
    <body>
    <span id="Message" MaintainState="false" runat="server" />
    <p>
    <b>Enter some text:</b> <br>
    <input id="MyText" type="text" value="Type a value here."
    style="font: 14pt verdana;width:300;" runat="server"/>

    </body>
    </html>


    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Client
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "John Spiegel" <> wrote in message
    news:%...
    > Hi all,
    >
    > How can I read through the style attributes for a server control? It
    > would
    > be so convenient if one could reference an index, something like:
    > pnlPageHeader.Style.Keys["Top"].ToString();
    >
    > TIA,
    >
    > John
    >
    >
    Chris Jackson, Feb 6, 2004
    #2
    1. Advertising

  3. John Spiegel

    Shahar Guest

    "John Spiegel" <> wrote in message news:<#>...
    > Hi all,
    >
    > How can I read through the style attributes for a server control? It would
    > be so convenient if one could reference an index, something like:
    > pnlPageHeader.Style.Keys["Top"].ToString();
    >
    > TIA,
    >
    > John


    pnlPageHeader.Style["Top"] = "5";
    Response.Write(pnlPageHeader.Style["Top"]);
    Shahar, Feb 6, 2004
    #3
  4. John Spiegel

    John Spiegel Guest

    Thanks, Chris and Shahar!

    Once I remembered case-sensitivity, the ["TOP"] indexing worked quite well!

    - John

    "John Spiegel" <> wrote in message
    news:#...
    > Hi all,
    >
    > How can I read through the style attributes for a server control? It

    would
    > be so convenient if one could reference an index, something like:
    > pnlPageHeader.Style.Keys["Top"].ToString();
    >
    > TIA,
    >
    > John
    >
    >
    John Spiegel, Feb 6, 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. Harry
    Replies:
    3
    Views:
    539
    Harry Singh
    Nov 10, 2003
  2. HS1
    Replies:
    3
    Views:
    484
  3. HS1
    Replies:
    4
    Views:
    8,294
    Babu Kalakrishnan
    Dec 8, 2004
  4. JC
    Replies:
    1
    Views:
    742
    Michael Rauscher
    Aug 9, 2006
  5. Ken Varn
    Replies:
    0
    Views:
    439
    Ken Varn
    Apr 26, 2004
Loading...

Share This Page