ASP.NET with C#:
I have a web page which is intended to be a help page. Actually I am using a treeview component, and when someone clicks on a node a label on the page will change text by reading it from text file.
what I want is to put some images in the help so a .txt file will not be suitable. So I may use a .html file instead.
How to read such a .html file and display it in my page? May I replace the label with some thing else or what?
Use ASP.NET Literal control instead. The Literal control is used to display text on a page. The text is programmable.
Note: This control does not let you apply styles to its content!
<asp:Literal />
Use <asp:PlaceHolder runat="server"> - it's a more general purpose way of inserting blocks of content into a page.
Use placeholder or literal asp control, because these controls don't put any html for its self, it just render whats inside.
But for example the normal asp label will render as a span.
Related
I am using C# WinForms.
I want to display HTML formatted content in a Label control. Is it possible to do this? How can I do this?
A label is not meant to display formatted text. You can apply only one format to a label, which will be applied to the whole string.
If you want to display HTML-formatted text in a Windows Forms form, you'd better use a WebBrowser control instead of a label.
Source : http://www.codeproject.com/Answers/1121356/Display-HTML-formatted-string-in-to-label
You can do this but with correct approach
either use
<asp:PlaceHolder runat="server">
or can
try
<asp:Literals>
I'm building a kind of simple In-Application CMS and I'm gonno let the user to upload an HTML and a CMS file as Masterpage.
A solution I thought was asking user to put some Pre-Defined Tags inside HTML so I can replace them with ContentPlaceHolder control. The reason of replacing ContentPlaceHolder is that I may have some Web Controls and need postback handling so I cannot convert everything to Html and put them to an HTML and push to client.
And the Questions:
1- Is there any better solution?
2- Is it possible? How can I replace some string with CPH Control?
Regards
To my knowledge you cannot dynamically generate content placeholders at runtime. So your actual masterpage will have to have them in place ahead of time.
I think you may be able to achieve what you are after by putting Literal controls before and after each content placeholder. Then you could parse your CMS html to determine which html comes before a placeholder and which comes after. Finally set each Literal's text property to the respective parsed html.
I have a page where I am showing user input content in a literal control, The user input text may be html. and the html content contains an href which is a .css file, and when showing in page the style in .css file affect the whole page.
how can i solve the issue?
thanks,
Place the content in an iFrame which will render in its own DOM and then make the iFrame fit into your design somehow.
I think you can use Literal Mode property.
Mode = "Tranform"
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.mode%28v=vs.110%29.aspx
As per the link
Transform
Unsupported markup-language elements are removed from the contents of the control. If the Literal control is rendered on a browser that supports HTML or XHTML, the control's contents are not modified.
Just wanna ask anyone here knows why when i put a placeholder in my masterpage it became like this
[ PlaceHolder "PlaceHolder1" ]
It supposed to be a blank editable box right? I cant even write anything there.
Help me ya. Thank you.
I think you need ContentPlaceHolder instead of PlaceHolder.
Use the PlaceHolder control as a container to store server controls
that are dynamically added to the Web page. The PlaceHolder control
does not produce any visible output and is used only as a container
for other controls on the Web page.
When ContentPlaceHolder is used to hold content from Content Pages and can only be used on a Master Page
You need to add Content Place Holder rather than placeholder
A placeholder is used to reserve some place for dynamically added controls
It is not a blank editable textbox
If you need a textbox for editing, just drop a simple server side textbox control & set its text mode to multiline inside properties.
W3Schools:ASP.NET Placeholder
I use Asp.net 4 and C#.
I have a common web control <asp:Panel>. It is my understanding that if the Panel is visible it renders in the Browser as a <div></div> tag.
I would like to know if is possible to change this behavior and display the content of the Panel without rendering its <div>.
Any idea how to do it?
Can I use another control instead of Panel?
An example of code would be appreciated thanks!
Simple :
use PlaceHolder or Literal
it renders only what it has - nothing more nothing less.
If you use an ASP.NET PlaceHolder control then you will not get the div tags.
Of course if you use a PlaceHolder you will not get a HTML element for this (i.e. a DIV tag) so you cannot set properties such as BackImageUrl or Wrap, etc. on the control.