Define exactly position an Object in webform?

Last post 04-27-2009 2:40 PM by gebetita. 2 replies.

Sort Posts:

  • Define exactly position an Object in webform?

    07-20-2007, 10:08 AM
    • Member
      point Member
    • whamy04
    • Member since 05-21-2007, 1:56 AM
    • Posts 18

     In Winform, i know method Location = new Point to define exactly position a new object ( textbox, button,....). But in webform, how can i do it?I cannot find this method?

    I want to creat automatically an object when i click other object.Ex : click a button, automatically create a textbox, and i want to define exactly position of this texbox in my webform like 50,50. 

  • Re: Define exactly position an Object in webform?

    07-25-2007, 4:16 AM
    Answer

    Hi whamy04,

    From your description, I understand that you want to dynamically create a TextBox control. In addition, the position of the TextBox control should be “top:50px and left:50px”. For this scenario, please refer to the following code.

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:Button ID="Button1" runat="server" Text="Create TextBox" OnClick="Button1_Click" />
                <br />
                test test test test test test test test test test
                <br />
                test test test test test test test test test test
            </div>
        </form>
    </body>
    </html>

    ************** code behind
            protected void Button1_Click(object sender, EventArgs e)
            {
                TextBox tb = new TextBox();
                tb.Style.Add("POSITION","absolute");
                tb.Style.Add("TOP", "50px");
                tb.Style.Add("LEFT", "50px");
                HtmlTextWriter myhtw = new HtmlTextWriter(new StringWriter());
                tb.RenderControl(myhtw);
                Response.Write(myhtw.InnerWriter.ToString());
            }   

     

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
  • Position of Button in a multiview page using APS.net

    04-27-2009, 2:40 PM
    • Member
      2 point Member
    • gebetita
    • Member since 04-27-2009, 2:29 PM
    • Posts 6

    Hi Benson,

     

    I have three buttons which will display different views in my form(multiview)  Each views are displayed using buttons let say (Red, Green and Yellow)

    If I click Red ,the Red form shows, If Click Green, the Green form shows. etc.

    What I want to do is to create a button available to each views but will be positioned depending on the view state


    For example:

     

    I have a button called "Load Data"

    If I click Red, the button "Load Data" goes to top: 50 px and left : 50 px

    If I click  Green , the the button "Load Data" goes to top: 120 px and left : 60 px

    If I click  Yellow , the the button "Load Data" goes to top: 100 px and left : 30 px

    Please help.

    Thank you

    Gerry

     

    Filed under: ,
Page 1 of 1 (3 items)