change attribute in html elements

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default change attribute in html elements

    How can I change attribute in html elements from my aspx.cs page?



    For example if I want to change the src-attribute in an iframe.



    //Linus


    Linus Martinsson Guest

  2. Similar Questions and Discussions

    1. Adding a change event to a Date attribute of a customcomponent.
      How do I add a change event for a custom attribute on a custom component? Example code: ...
    2. Web Custom Control, design-time property doesn't change attribute
      Hi, This seems to be a simple problem, but I am unable to figure out what is wrong: I have a Web Custom Control, with two properties (both are...
    3. how to add class attribute to html code?
      Hi, I have a control that has a property. The property is a class type. I have made it expandable in property grid like fontinfo class. But I...
    4. Change <link> href attribute dynamically
      Hello Amir, "Amir Eshterayeh" <aeshterayeh@hotmail.com> schrieb im Newsbeitrag news:epFJJx5AEHA.2632@TK2MSFTNGP12.phx.gbl... I'd use a...
    5. Specifying string array as an attribute in HTML tag
      This might be obvious, but I can't quite figure out the syntax to do it. How does one specify a string array in the actual HTML for a control? For...
  3. #2

    Default Re: change attribute in html elements

    when i want to change the attribute of a htmlcontrol in c#, i use:

    HtmlControl.Attributes["attributename"] = "attributevalue"

    eg: oHtmlTableCell.Attributes["class"] = "headercell";

    hope this helps you.!


    "Linus Martinsson" <Linus.martinsson@swipnet.se> wrote in message
    news:epG2GAbVDHA.2104@TK2MSFTNGP10.phx.gbl...
    > How can I change attribute in html elements from my aspx.cs page?
    >
    >
    >
    > For example if I want to change the src-attribute in an iframe.
    >
    >
    >
    > //Linus
    >
    >

    suzy Guest

  4. #3

    Default Re: change attribute in html elements

    Make the html object into a server side control.

    1) Add and id="myobject" and runat="server" attributes to the object in the
    html code:

    <iframe id="MyIframe" runat="server"></iframe>

    2) Dim the object in your codebehind page as a
    System.Web.UI.HtmlControls.HtmlGenericControl:

    Protected MyIframe As System.Web.UI.HtmlControls.HtmlGenericControl

    3) Now you may add attibutes dynamically as suzy suggests.

    MyIframe.Attributes.Add("[Attribute Name]", "[Attribute Value]")

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    [url]www.aboutfortunate.com[/url]

    "Out of chaos comes order."
    Nietzche
    "Linus Martinsson" <Linus.martinsson@swipnet.se> wrote in message
    news:epG2GAbVDHA.2104@TK2MSFTNGP10.phx.gbl...
    > How can I change attribute in html elements from my aspx.cs page?
    >
    >
    >
    > For example if I want to change the src-attribute in an iframe.
    >
    >
    >
    > //Linus
    >
    >

    S. Justin Gengo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139