In general i guess set the width of the button in pixel, rather in %, so that changing the resolution wont affect its width, and also have put your button inside the table's <td>....
If i am right your button controls show correct position and size at the design time and its size is increased big at the run time.
I too faced the similar problem at the beginning and i solved it by putting all the controls in a table. Create a table and put all your controls in it, Align them properly and i think thats the way you can solve your problem.
Click “Mark as Answer” on the post(s) that helped you.
I just saw yur code in design time, i find Style="z-index: 100; left: 260px; position: absolute; top: 40px"
added in all yur controls, remove this portion from your controls and then try it, then u will find the controls positioned properly.
To have a more better layout creat html table inside the
<asp:Content... and then place yur controls.
I have removed those Style entry from yr controls and pasting the code below for yur reference....
Well the problem with your asp:button's style. here i modified your code by adding it with table,tr and td. ... Copy and paste this code to your project.. and see how it look..
well it is better if u put the controls in grid view because when grid view is populated every time wen u add a record , whatever the controls after the gridview will be in a fixed position adjusting to the gv's size.
Thanks
Swapna
Please click "mark as answer" if this post helped you.
better you put the button inside Div tag. Give width,height and style to Div tag.
or in Code behind you can code like this.I wrote some default styles you can change that.
Dim div011 As HtmlGenericControl = New HtmlGenericControl()
div011.Style.Add("float", "left")
div011.Style.Add("width", "px")
div011.Style.Add("height", "px")
Dim button1 As New button
hyp1.Style.Add("color", "#4566A3")
div011.Controls.Add(maindiv)
Kannandesika...
Member
368 Points
764 Posts
button position problem
Mar 11, 2008 04:52 AM|LINK
Hi,
i have two button in a page after run that page the postion of the button is big and not in the right place
how to set button in the particular place i need --- this very big problem for me how to slove
please guide me.
btndiscard width is very large
Kannandesikan
vik20000in
All-Star
25882 Points
3993 Posts
MVP
Re: button position problem
Mar 11, 2008 05:05 AM|LINK
Can you show us your aspx code so that we can help you?
www.vikramlakhotia.com
Please mark the answer if it helped you
s.sriram
Member
590 Points
94 Posts
Re: button position problem
Mar 11, 2008 05:12 AM|LINK
Hi,
Can u post some code of yours for us to see.
In general i guess set the width of the button in pixel, rather in %, so that changing the resolution wont affect its width, and also have put your button inside the table's <td>....
Kannandesika...
Member
368 Points
764 Posts
Re: button position problem
Mar 11, 2008 05:15 AM|LINK
Hi,
herewith iam sending the aspx code ,please lot the highlighted potion
<%@ Page Language="VB" MasterPageFile ="~/IPLCoupon.master" CodeFile="Policytypemaster.aspx.vb" Inherits="Policytypemaster" %>
<asp:Content ID ="policy" runat ="server" ContentPlaceHolderID ="ContentPlaceHolder1">
<asp:Label ID="lbltypename" runat="server" Style="z-index: 100; left: 260px; position: absolute;
top: 40px" Text="Type Name" Width="100px"></asp:Label>
<asp:Label ID="lbltypedesc" runat="server" Style="z-index: 101; left: 260px; position: absolute;
top: 70px" Text="Type Description" Width="120px" Height="20px"></asp:Label>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Style="z-index: 102;
left: 260px; position: absolute; top: 100px" Height="1px" Width="370px" DataKeyNames="FldCCode">
<Columns>
<asp:TemplateField HeaderText="Couponcode" Visible="False">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FldCCODE") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FldCCODE") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Couponname">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("fldMeaning") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("fldMeaning") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Select">
<EditItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# ischecked(eval("fldactivate")) %>' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Enabled="true" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:HiddenField ID="HiddenField1" runat="server" Value="keys" />
<asp:TextBox ID="txttypename" runat="server" Style="z-index: 103; left: 410px; position: absolute;
top: 40px" Width="180px"></asp:TextBox>
<asp:TextBox ID="txttypedesc" runat="server" Style="z-index: 104; left: 410px; position: absolute;
top: 70px" Width="180px"></asp:TextBox>
<br />
<asp:GridView ID="gridpolicy" runat="server" AutoGenerateColumns="False" DataKeyNames="fildtcode"
Style="z-index: 105; left: 240px; position: absolute; top: 290px" Width="400px">
<Columns>
<asp:BoundField DataField="fildtcode" HeaderText="polcode" Visible="False" />
<asp:TemplateField HeaderText="Policy Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("fldpolname") %>' Enabled="False"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("fldpolname") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("fldpoldesc") %>' Enabled="False"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("fldpoldesc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" InsertVisible="False" UpdateText="" />
</Columns>
</asp:GridView>
<asp:Button ID="btnupdate" runat="server" Style="z-index: 106; left: 350px; position: absolute;
top: 260px" Text="Update" Width="70px" />
<asp:Button ID="btnsave" runat="server" Style="z-index: 107; left: 200px; position: relative;
top: 160px" Text="Save" Width="60px" />
<asp:Button ID="btndiscard" runat="server" Style="left: 520px; position: relative;
top: 260px" Text="Discard" />
</asp:Content>
Kannandesikan
jagan.unique
Participant
1286 Points
245 Posts
Re: button position problem
Mar 11, 2008 05:24 AM|LINK
Hi Kannandesikan,
If i am right your button controls show correct position and size at the design time and its size is increased big at the run time.
I too faced the similar problem at the beginning and i solved it by putting all the controls in a table. Create a table and put all your controls in it, Align them properly and i think thats the way you can solve your problem.
s.sriram
Member
590 Points
94 Posts
Re: button position problem
Mar 11, 2008 05:29 AM|LINK
Hi,
I just saw yur code in design time, i find Style="z-index: 100; left: 260px; position: absolute; top: 40px" added in all yur controls, remove this portion from your controls and then try it, then u will find the controls positioned properly.
To have a more better layout creat html table inside the <asp:Content... and then place yur controls.
I have removed those Style entry from yr controls and pasting the code below for yur reference....
<%@ Page Language="VB" MasterPageFile ="~/IPLCoupon.master" CodeFile="Policytypemaster.aspx.vb" Inherits="Policytypemaster" %>
<asp:Content ID ="policy" runat ="server" ContentPlaceHolderID ="ContentPlaceHolder1">
<asp:Label ID="lbltypename" runat="server" Text="Type Name" Width="100px"></asp:Label> <asp:Label ID="lbltypedesc" runat="server" Text="Type Description" Width="120px" Height="20px"></asp:Label> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Height="1px" Width="370px" DataKeyNames="FldCCode"> <Columns> <asp:TemplateField HeaderText="Couponcode" Visible="False"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FldCCODE") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("FldCCODE") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Couponname"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("fldMeaning") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("fldMeaning") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Select"> <EditItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# ischecked(eval("fldactivate")) %>' /> </EditItemTemplate> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Enabled="true" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:HiddenField ID="HiddenField1" runat="server" Value="keys" /> <asp:TextBox ID="txttypename" runat="server" Width="180px"></asp:TextBox> <asp:TextBox ID="txttypedesc" runat="server" Width="180px"></asp:TextBox> <br /> <asp:GridView ID="gridpolicy" runat="server" AutoGenerateColumns="False" DataKeyNames="fildtcode" Width="400px"> <Columns> <asp:BoundField DataField="fildtcode" HeaderText="polcode" Visible="False" /> <asp:TemplateField HeaderText="Policy Name"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("fldpolname") %>' Enabled="False"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("fldpolname") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Description"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("fldpoldesc") %>' Enabled="False"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("fldpoldesc") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" InsertVisible="False" UpdateText="" /> </Columns> </asp:GridView> <asp:Button ID="btnupdate" runat="server" Width="70px" /> <asp:Button ID="btnsave" runat="server" Text="Save" Width="60px" /> <asp:Button ID="btndiscard" runat="server" Text="Discard" /> </asp:Content>Please let me know if you have any other problems......
swapnasamson...
Member
410 Points
299 Posts
Re: button position problem
Mar 11, 2008 05:43 AM|LINK
Hi Kannan,
Well the problem with your asp:button's style. here i modified your code by adding it with table,tr and td. ... Copy and paste this code to your project.. and see how it look..
<%@ Page Language="VB" MasterPageFile ="~/IPLCoupon.master" CodeFile="Policytypemaster.aspx.vb" Inherits="Policytypemaster" %> <asp:Content ID ="policy" runat ="server" ContentPlaceHolderID ="ContentPlaceHolder1"> <center> <table> <tr> <td> <asp:Label ID="lbltypename" runat="server" Text="Type Name" Width="100px"></asp:Label> </td> <td> <asp:TextBox ID="txttypename" runat="server" Width="180px"></asp:TextBox> </td> </tr> <tr> <td> <asp:Label ID="lbltypedesc" runat="server" Text="Type Description" Width="120px" Height="20px"></asp:Label> </td> <td> <asp:TextBox ID="txttypedesc" runat="server" Width="180px"></asp:TextBox> </td> </tr> <tr> <td colspan="2"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Height="1px" Width="370px" DataKeyNames="FldCCode"> <Columns> <asp:TemplateField HeaderText="Couponcode" Visible="False"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FldCCODE") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("FldCCODE") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Couponname"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("fldMeaning") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("fldMeaning") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Select"> <EditItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# ischecked(eval("fldactivate")) %>' /> </EditItemTemplate> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" Enabled="true" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </td> </tr> <tr> <td colspan="2"> <asp:GridView ID="gridpolicy" runat="server" AutoGenerateColumns="False" DataKeyNames="fildtcode" Width="400px"> <Columns> <asp:BoundField DataField="fildtcode" HeaderText="polcode" Visible="False" /> <asp:TemplateField HeaderText="Policy Name"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("fldpolname") %>' Enabled="False"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("fldpolname") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Description"> <EditItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("fldpoldesc") %>' Enabled="False"></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("fldpoldesc") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:CommandField ShowEditButton="True" InsertVisible="False" UpdateText="" /> </Columns> </asp:GridView> </td> </tr> <tr> <td colspan="2"> <asp:Button ID="btnupdate" runat="server" Text="Update" Width="70px" /> <asp:Button ID="btnsave" runat="server" Text="Save" Width="60px" /> <asp:Button ID="btndiscard" runat="server" Text="Discard" /> </td> </tr> </table> </center> <asp:HiddenField ID="HiddenField1" runat="server" Value="keys" /> </asp:Content>well it is better if u put the controls in grid view because when grid view is populated every time wen u add a record , whatever the controls after the gridview will be in a fixed position adjusting to the gv's size.
Swapna
Please click "mark as answer" if this post helped you.
sreenatht
Member
296 Points
136 Posts
Re: button position problem
Mar 11, 2008 06:19 AM|LINK
better you put the button inside Div tag. Give width,height and style to Div tag.
or in Code behind you can code like this.I wrote some default styles you can change that.
Dim div011 As HtmlGenericControl = New HtmlGenericControl()
div011.Style.Add("float", "left")
div011.Style.Add("width", "px")
div011.Style.Add("height", "px")
Dim button1 As New button
hyp1.Style.Add("color", "#4566A3")
div011.Controls.Add(maindiv)
Thanks & Regards,
Sreenath.T
Senior Software Engineer
UST Global
Mobile- +919605009304
sreenatht.blogspot.com
http://in.linkedin.com/in/sreenatht