Click here to Skip to main content
15,904,926 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
design time we are design page with controls but we need to increase and decrease controls top size based on condition how can i resolve this by using javascript or jquery in asp.net, below mentioned my controls code some of controls i need to display default and some of controls i need to display based on condition but the controls allignment always top

What I have tried:

Quote:
<asp:label id="lblEmpID" style="Z-INDEX: 100; LEFT: 8px; POSITION: absolute; TOP: 42px" runat="server" CssClass="labelBoldClass">Employee ID
<asp:label id="lblDispEmpID" style="Z-INDEX: 115; LEFT: 136px; POSITION: absolute; TOP: 42px" runat="server" CssClass="fieldClass">Employee ID
<asp:label id="lblFirstName" style="Z-INDEX: 100; LEFT: 8px; POSITION: absolute; TOP: 74px" runat="server" CssClass="labelBoldClass">First Name
<asp:textbox id="txtFirstName" style="Z-INDEX: 115; LEFT: 136px; POSITION: absolute; TOP: 72px" runat="server" Width="250px" MaxLength="14" CssClass="fieldClass" tabIndex="1">
<cc1:AbraRequiredFieldValidator ID="arfvFirstName" ControlToValidate="txtFirstName" style="LEFT: 126px; POSITION: absolute; TOP: 77px" runat="server">
<asp:label id="lblMiddleName" style="Z-INDEX: 116; LEFT: 8px; POSITION: absolute; TOP: 106px" runat="server" CssClass="labelBoldClass">Middle Name
<asp:textbox id="txtMiddleName" style="Z-INDEX: 113; LEFT: 136px; POSITION: absolute; TOP: 106px" tabIndex="2" runat="server" Width="250px" MaxLength="14" CssClass="fieldClass">
<asp:label id="lblLastName" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 138px" runat="server" CssClass="labelBoldClass">Last Name
<asp:textbox id="txtLastName" style="Z-INDEX: 111; LEFT: 136px; POSITION: absolute; TOP: 138px" tabIndex="3" runat="server" Width="250px" MaxLength="25" CssClass="fieldClass">
Posted
Updated 4-Oct-18 4:13am
Comments
ZurdoDev 4-Oct-18 10:09am    
I would suggest googling how to change css properties using jQuery.

1 solution

Use the control's id and set the top with css. For example (JQuery), let's say you wanted to increase the top of the first name label by 250

JavaScript
var newtop = $('#lblFirstName').position().top + 250;
$('#lblFirstName').css('top', newtop + 'px');


Please keep in mind that ASP will change the lables and you will have to account for that. You would probably be better off applying a common class to the elements you want to adjust and then you could adjust all fields at once by reference the class.

var newtop = $('.adjustabletopclass').position().top + 250;
$('.adjustabletopclass').css('top', newtop + 'px');
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900