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
Related
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 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.
I have a table similar to:
ID...NAME.....HTMLTEXT
1....Footer....`<b>test</b>`
where each entry has some HTML text and an associated Name and ID.
What I want to do in ASP.net C# is to list each of these entries on a page in such a way that the HTML text should be displayed exactly how it is meant to be (e.g. <b>test</b> should show 'test' in bold) and each entry should be editable. When the Edit button is clicked on an entry, the HTML text should be replaced by a textbox with the text inside it so that you can edit it and save it.
For example:
FOOTER --EditButton--
TEXT
test
Now I am not sure on what is the best way to do this. Should I use a repeater with an ItemTemplate for each entry? If I use a repeater, and an edit button is clicked, how do I know which edit button is clicked and how do I know which textbox to display the text etc?
You could also use a ListView - I tend to use this because its pretty robust. The data bound controls support the <%# Bind("Field") %> statement. You setup your templates in ItemTemplate or EditItemTemplate, and if you add the proper commands to the buttons in the UI, it all wires up the proper events for you (depending on how you data bind). If you don't use a datasource control, you have to manually tap into the ItemEditing, ItemUpdating, etc. events.
Additionally, if you need to, you can get references to the controls using the current item's FindControl("ID") method.
HTH.
Create a custom control (.ascx) and on this control make the line with the view that you wish, and handle the change/save/delete etc.
Then place this control in the repeater and just give him an id to load and edit.
Does anyone have any ideas how to create a function that resizes text on a page dynamically without the use of JavaScript? I'm using CMS based on C#?
Is it possible with CSS only? if it's not possible then i want to do with javascript like this page http://demo.joomla.org/1.5/?template=beez and as a fallback want to user server side solution which this page hasn't http://demo.joomla.org/1.5/?template=beez
Without javascript? Well, guess you will have to perform a postback onchange, then perform resize in your codebeind. Not very user friendly though.
I doubt CSS can do that.
You could create 3 links:
A A A
Then on postback, use the value of the 'size' query string attribute as a CSS font-size value. something like (pseudocode)
// aspx
<div style="font-size:<%= getsize(); %>"> ...
// code behind
getsize(){
return Request.QueryString["size"];
}
If you are getting size from database then you can do one thing:
Create a panel and put all controls in it and set size dynamically.
See following for more details:
http://asp-net-example.blogspot.com/2009/04/how-to-set-change-panel-font-size.html
I think you are misunderstanding something, you want a C# function for something that is fundamentally client side? Do you want to do it after the page has loaded or before? You can resize text on a page with CSS easily.
body{ font-size:60%; }
If you are looking for say 3 sizes (standard, large, huge) then the way I've done this is to create the visual elements as ImageButtons or CSS'ed Buttons to style them to fit the design.
You can then hold the body{font-size:1em;} outside of the CSS includes (but before it in the head section) within a Literal to honor the browser defaults by default. When the postback occurs you can adjust the literal accordingly - e.g. large would be adjusted to body{font-size:1.5em}.
litFontSize.Text = "body{font-size:1.5em;}"
You do need to check that the body font-size is being inhereted throughout though, cross browser - form text for one will need independent definiton in my experience.
What do you want to trigger the dynamic-resizing? The window being resized? Or the user pressing a button?
If you want to resize text when a user resizes the window, then no - you won't be able to do that with CSS alone, since CSS doesn't have any way of setting font sizes based on the window size. Every site I've seen that does this does it via javascript.
If you want the trigger to be a button press, then this is pretty simple - the button sends a postback to the server, you pick up their desired size from a dropdown or from the specific button that was pressed, and then you can add some CSS into the page or add a link to a different stylesheet.
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.