Add div to specific Div ASP - asp.net

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.

Related

How to change the Ajax combo box list items width dynamically from code behind?

I have a Ajax combo box whose width is set from a css class, i want to change the width of list items (the area which appears after we click the button on combo box present at right side). from the code behind.
I've set the width of listitems from css like
.ComboboxWidth ul
{
width:176px !important;
}
This works. But i've to do same thing from code behind, can anybody guide?

Remove DIV from Master Page

Is there a way to REMOVE a DIV of the master page? not hide, there are some hyperlinks in the div, so I want to remove them from the code as well. thanks
By using HTML DOM you can actually remove any element you want. You need to use JavaScript or jQuery to achieve this.
var div = document.getElementById("task_row_" + taskId);
div.parentNode.removeChild(div);
Reference: Remove DIV tag using Javascript or Jquery
You could do the following:
<div id="random_name" runat="server" visible="false">
content
</div>
That will allow you to hide the div, but also from the .net show & hide it as well using.
random_name.visible = true
The use of Visible, doesn't just hide it from the view but show it in the code, it completely hides it, not view able by the client at all.
For changing content of master page from child page check out my answer from:
Disable Hyperlink of Master page from content page

Making false the readonly of a Div

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>

How to create USER CONTROL like panel and Header Portion should have fixed design

I want create a user control (Div) like panel and Header Portion should have fixed design to be used in all my web pages. For example, The UserControl can have two DIV or TR with a background design. first DIV has FIxed design and second has to be CONTENT PLACE HOLDER. If it's added to a Page, the UserControl has to allow controls to be added into CONTENT PLACE HOLDER, i.e. Labels, and TextBoxes . The height of the div should be AUTO. Please help me.
Why not use a custom control approach instead, by creating a class that inherits from panel, like the following:
http://www.codeproject.com/KB/custom-controls/panelcurvecontainer.aspx
HTH.

How to hide an iframe using a button in the content page?

Hai ,
I am using an iframe for showing a page in my website. i want to hide that frame using a close button in the content page( the page which is showing in the frame)
How to do this? use jQuery
See this image
You can use a client side script to make the iframe invisible. Lets consider the IFrame is inside a div <div id="iFrameContainer"><iframe></iframe></div>. In such a case you can fire a javascript on click of the button and set something like document.getElementById("iFrameContainer").visible=false; This should work for you.
have your iframe in your div tag. Then execute the following statement for hiding or displaying respectively when button get onclick event.
document.getElementById('iframeid').style.display='none'; // hiding
document.getElementById('ifrmaeid').style.display='block'; // displaying
As iframe is html control it will pruduce an erroe while running it at the sever...
To make the iframe hide or show at particular condition ... we can use apply simple trick.. take a div element which will wrap the iframe element.. eg
<div id="vidPreview" runat="server" visible="false">
<iframe src="demo.aspx" width="400" height="200" frameborder="0" style= "background-color:Black;"></iframe>
</div>
When u want to make visible just make that div's visibility property=true
in above eg make...vidPreview=true whenever i want to display iframe..

Resources