I want to relocate a dropdownlist control based on the login status of a user.
How do I set the Z-Index, LEFT,POSITION etc programatically?
Is this done via .styles?
thx....
Printable View
I want to relocate a dropdownlist control based on the login status of a user.
How do I set the Z-Index, LEFT,POSITION etc programatically?
Is this done via .styles?
thx....
Yes.
But be aware - you want to be sure to replace the default <DOCTYPE definition VS provides for the web pages. You will want to use a fully qualified doctype decleration with the one provided below. This is especially important if your site will be viewable by browsers other than Internet Explorer.
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/tr/rec-html40/loose.dtd">
I'm not sure I understand, could you provide an example?
I'm assuming something like DropDownList.Styles(?)
or DropDownList.Styles(?)=?
I'm not sure if I'm to provide as an argument or as an assignment and what method to use. THX :afrog:
Are you trying to change it's placement ServerSide or ClientSide? Meaning or we using JavaScript or Asp.Net?
I want to do server side.
ie:
txtMyTextbox.text="hello"
txtMyTextbox.visible=false
Are pretty straight forward but...
MyDropDownList.Style ?????
I think is what I want to relocate (in my case a DropDownList) on the form.
Look. Page_Load and the button code.
ASPX/HTML
CoidebehindCode:<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="tb_nDg.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 7px; POSITION: absolute; TOP: 7px" runat="server"></asp:DropDownList>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 145px; POSITION: absolute; TOP: 23px" runat="server" Text="Button"></asp:Button>
</form>
</body>
</HTML>
PHP Code:public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
DropDownList1.Style["left"] = "100px";
DropDownList1.Style["top"] = "100px";
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
System.Random r = new System.Random(500);
DropDownList1.Style["left"] = r.Next(500).ToString() + "px";
DropDownList1.Style["top"] = r.Next(500).ToString() + "px";
}
}
Perfect!-Thanks just what I was looking for.
:bigyello:
Works great!