I am using a multiline textbox for publishing a note but taking the content in a div through inner HTMl.
like this
divMessageDescription.InnerHtml = dbreader["Message"].ToString();
but now for a particular group of people I want to make the read only property of this div as false..
Can I do this ???
Why use div for text editing, you can use multi-line text box (textarea). Even for display purpose, you may use the same textbox with read-only set as true.
To make the div editable (read only = false) you use the contentEditable="true"
<div id="divMessageDescription" contentEditable="true">
click here to edit ...</div>
Related
I am using CSS3 resizable property to resize an HTML Div element.
Here is sample code : http://jsfiddle.net/blunderboy/nMTm9/1/
But, I want to update the value inside input element as soon as width of div changes. How can we achieve this ?
With setInterval, you can do this:
http://jsfiddle.net/nMTm9/3/
It's not perfect but works great.
var input = $('input'), div = $('#resizable');
function calculate(){
input.val(div.width()+"px");
}
setInterval(calculate,500);
No, CSS cannot change the value attribute of an input, or indeed any attribute of any element.
The close change content by style is if you put content in the input field or erased the content input field the label change by css.
enter link description here
I need to create user control with Texbox Textmode="Multiline" or html textarea.
When in edit mode Textbox/textarea has to be resizable. I can use some jquery plugin for this. But in read only mode this Textbox/textarea is disabled and it must be automatically resized (height) to fit the text. Even if text takes pages. I could just hide Textbox/textarea in read only mode and display text in div but I would like to keep edit and readonly page look same.
Any ideas?
Why have textarea/input in readonly mode - versus using js to switch back and forth between that control and a DIV or a P tag (to display the text), where simply by not setting the height (or setting it to height:auto) that box would automatically size to contain all text?
Also, unless your surrounding content doesn't allow that, enable resizing the textarea to the user; see http://davidwalsh.name/textarea-resize
In this project I'm working on they made divs that look like textboxes that contain data. Then when you click onto the div they change to read-write textboxes. When this happens the textboxes are a little bigger than the original div size (width).
Outside of changing the divs to R/O textboxes and then flipping them to R/W textboxes is there a way to get the width of the original div and pass it into the size of the newly shown textbox.
Basically, the textbox is hidden at first (1 hidden textbox per screen). When the user clicks on a div, the hidden textbox is shown and moved to the location where the div was (over the top). When the textbox text value changes and is moved off focus the div's innerHTML is changed and then the textbox is moved down the screen.
What I need to have happen is the div's original size could be a small text box or a long text box. When the onclick happens I need the textbox width to be the exact same size as the original div size.
Clear as mud right?
Any help is appreciated.
Have you considered using content editable divs?
Look into designMode, and contentEditable in order to forego using text areas all together. This way the size will remain consistant.
Something like the following may work. Please don't copy/paste as I wrote it in a hurry.
<div id='your_div' onClick='toggle();'> Stuff </div>
<script>
var a_div = document.getElementByID('your_div');
toggle = function() {
if(a_div.designMode) {
a_div.designMode = (a_div.designMode == false) ? true : false;
} else {
a_div.contentEditable = (a_div.contentEditable == false) ? true : false;
}
}
</script>
I would like to add div's and text to a specific DIV with ASP.NET, i have only found code which allowed controls to be added to the body but not to a specific Div.
I'm assuming you want to add controls and text to the div element server-side. If so, you can simply add runat and id attributes to the div and it will be available to you on the server.
For example, if you have a div on your page declared like this:
<div id="MyDiv" runat="server"></div>
You can add text, html content or other controls to it using the following:
MyDiv.InnerText = "some inner text"; // adding text
MyDiv.InnerHtml = "<div>inner html</div>"; // adding html
MyDiv.Controls.Add(new LiteralControl("a literal control")); // adding a control
Change the outer div to an <asp:Panel control. A Panel renders to html as a normal div, and will make it easy to add items from server code.
I want to display a note to the user whenever the focus comes to a particular textbox i have written the note in a div and set its visibility to false what to do next
Instead of your div, put that text into a ToolTip property on the textbox control and ASP.NET will take care of it for you.