简体   繁体   中英

How to pass a full asp.net control or HTML tags from server code in C# to a specific place in HTML design?

I'm not sure if this is even possible, but I wonder if I can generate a full control that its tags are stored in a text property to HTML page. let's say that I have an <asp:Image....... /> or <div><i href=""/></div> as a Text, and it is stored in a property named X in.cs file , and I want this X to be placed in a specific line in the Html page.

is that possible?

in.cs file let's say I have something like this

X = @"<asp:Image ID = ""Image111"" runat = ""server"" ImageUrl = ""img.jpg"" />";

and in the HTML file I want this:

<body>
<form id="form1" runat="server">
    . 
    <!-- X comes here but as a real control -->
    .
    .
    .
</form>

I'm not sure if it is possible but I wish to find a way to do this, any way.

Thanks in advance, best regards.

I would change the way youre thinking about this. Sounds like what you want to do is create a server control then pass some sort of parameter into that control which will then change the output accordingly. If you were using razor you can also have helpers which would handle this sort of thing.

This might be of interest.

Pass data from a ASP.NET page to ASCX user controls loaded dynamically

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM