<div id=“div1” runat=“server” style="display:none>
<asp:button id=“ok” runat=“server” text=“X”>// need this on right of div1
<div id=“div2” runat=“server” style="display:none> asp control</div>
<div id=“div3” runat=“server” style="display:none> asp control</div>
<div id=“div4” runat=“server” style="display:none> asp control</div>
</div>
i div1 i need a button as well as other 3 divs
when i click a button1 div1 will be displayed true & depending on condition div 2 or 3 or 4 will be displayed in div 1
but with above i dont get it
if i have div1.Attributes[“style”] = “display:block”; from code behind i dont get the control in the position set
but instead if i use
div1.Visible = true ; i get as positioned as the control is made to attain position from code behind
Sorry I don’t do ASP, but what is that snippet you have in there?
How is it displaying now? How would you like this to differ in the final product? The code you have provided is scarce and replicating it on our end is impossible.
If you have a site, that would be very preferable. While this may technically be a positioning issue(?) most of your code is basically Javascript and ASP. Either way, hopefully we can help, but first we need enough so that we can run a test example page on our end, which means no ASP :).
This isn’t HTML, so don’t expect it to do anything meaningful in a browser. Browsers read HTML, not ASP. Your ASP code should be creating pure HTML and pumping that over to the browser.
Since it’s not HTML, styling it and Javascripting it should not work.
What you probably want for real HTML code is something like this:
<div id="div1">
<button id="ok" value="X">
<div id="div2"> asp control</div>
<div id="div3"> asp control</div>
<div id="div4"> asp control</div>
</div>
You can set a width on div1 with CSS
#div1 {
width: 500px;
overflow: hidden;
}
(or something)
The overflow hidden is going to be so that if we float the button to the right, div1 grows to contain it.
To get the button to the right, you can float it right
#div1 button {
float: right;
}
(it’s a good idea to also give button a width)
Make all the other divs invisible: #div1 div {
display: none;
}
Now use button’s id to target it with Javascript.
var button;
if (button = document.getElementById(‘ok’)) {
button.onclick = function() {
//logic here to change div2,3,4’s display style to ‘block’ instead of ‘none’;
}
}
post the HTML and CSS code you have right now. Also which browser you are looking in. In the browser go to View Source and that’s the HTML we want to see.
If you don’t have a
<!doctype html>
at the top of your HTML, browsers will not all look the same with a lot of CSS. You must have that line of code at the top.
Sounds like you need to have an element wrap around div1 and the ok button, and then give that, along with <div2> element, both the same width. Should cause them to stretch proportionately.