I'm experiencing some weird behaviour on my local machine, when I access a page on my test server everything is centered like I want. When I run the code on my local machine everything is left aligned, the centering is ignored.
The HTML is really simple so I don't see why this issue has suddenly started to happen.
<table>
<tr>
<td>
<asp:HyperLink NavigateUrl="" ID="hlPhoto" runat="server"><asp:Image ID="imgPhoto" runat="server" ImageUrl='<%# String.Format( "../images/mugshots/{0}", DataBinder.Eval(Container.DataItem,"Photo") )%>' /></asp:HyperLink>
</td>
</tr>
<tr>
<td valign="bottom" align="center">
<div>
<b>
<asp:Label ID="lblName" runat="server"><%# Eval("FullName")%></asp:Label></b> </div>
<div>
<asp:Label ID="Label1" runat="server"><%# Eval("Jobtitle")%></asp:Label></div>
<div>
<br />
<asp:HyperLink NavigateUrl="" ID="hlDetail" runat="server"><font size="2">Details</font></asp:HyperLink>
</div>
<div>
<asp:HiddenField ID="userID" runat="server" Value='<%# Eval("Jobtitle")%>' />
</div>
</td>
Related
So previously my login worked fine. And then I made some edits and it stopped working. Here are the edits I made to my website in between it going from working to not working.
I was trying to make a submit content page but I kept getting errors about not being able to contain a form inside a form. So I went over to my master page and removed the form tag and then added all the form tags I needed into each individual page. In the end I ended up removing all form tags and putting a single form tag around the content place holder in the master page.
I added a new table to my SQL database to store content submitted by users. I use Microsoft Server Express for my database.
The error I am getting is not an error in my console, it is just that my PostBackURL is loaded with out anything happen. Even if I enter a correct login (I have checked and the login info I tested is stored in my database), it will just automatically load the PostBackURL with no login occuring, nor any Login failed messages.
Web Config:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
<authentication mode="Forms">
<forms loginUrl="login.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
</configuration>
Master Page (Relevant Parts):
<body>
<form id="form1" runat="server">
<div class="header headerLogin">
<img style="margin-left: 5vw; margin-top: 5px; height: 32px; width: 130px;" src="images/inshortlogo.png" />
<p class="taskbarLinks">
HOME
NEWS
JOB LISTINGS
STUDY
LOGIN
</p>
<script>
...
</script>
</div>
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
Login Page:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="Absolute-Center">
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Login ID="Login1" runat="server">
<LayoutTemplate>
<table cellpadding="1" cellspacing="0" style="border-collapse:collapse;">
<tr>
<td>
<table cellpadding="0">
<tr>
<td align="center" colspan="2">Log In</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName" ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="ctl08$Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password" ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="ctl08$Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me next time." />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" CssClass="button" PostBackUrl="~/home.aspx" Text="Log In" ValidationGroup="ctl08$Login1" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
<br />
<div style="text-align: center;">
<a class="button" style="margin-right: 2em;" href="signup.aspx">Register</a>
<a class="button" href="forgotpassword.aspx">Forgot Password</a>
</div>
</AnonymousTemplate>
<LoggedInTemplate>
<asp:Label ID="logOutLabel" runat="server" Text=""></asp:Label>
<br />
<br />
<div style="text-align: center;">
<asp:LinkButton ID="logOutButton" runat="server" class="button" OnClick="logOutButton_Click">Log Out</asp:LinkButton>
</div>
</LoggedInTemplate>
</asp:LoginView>
</div>
<style>
.Absolute-Center {
position: absolute;
top: 50%;
left: 50%;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
</style>
</asp:Content>
Thanks in advance!
Remove the postbackurl. That posts the form to another page, so of course you don't get logged in. Instead, upon successful login, perform a redirect to whatever page you want.
I am having lot of space between newly added radiobuttons(yes and No) of the RadioButtonList and the first part of the existing region(divName) is aligned properly.
can any body help me in aligning the newly added second region(div1)
<div id="divpanelFacts" runat="server">
<fieldset id="panelFacts">
<table width="100%">
<tr>
<td>
<div id="divName" runat="server" visible="false">
<span>
<label runat="server" id="Label1">
<span id="pNameSpan" runat="server">*</span>P Name</label>
<asp:TextBox ID="textPName" runat="server" MaxLength="20"></asp:TextBox>
</span>
</div>
</td>
<td>
<div id="div1" runat="server" visible="false">
<asp:Label ID="lbl1" runat="server" Text="Would like to use this option for document purpose"></asp:Label>
<asp:RadioButtonList ID="rbl1" runat="server" TextAlign="Left" RepeatDirection="Horizontal">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" Selected="True" />
</asp:RadioButtonList>
</div>
</td>
</tr>
</table>
</fieldset>
</div>
Your table width is at 100%, which means it's going to stretch it, and table I think takes precedence.
I have a textbox centered on a page. What I would like to have is an error label display to the right of it, if necessary, and keep the textbox centered on the page. The page contains a Panel, which is centering the entire page.
<asp:Panel ID="pnlStart" runat="server" CssClass="center">
...
...
...
<tr>
<td>
<div>
<input type="text" id="pName" name="pName" runat="server" class="pName" style="color:#7A0000;width:33%;"
value="Enter Your Name" onfocus="inputFocus(this)" onblur="inputBlur(this)" />
<asp:Label ID="pNameValidationLabel" style="width:33%;" name="pName" runat="server" Text="*Please enter your name." class="pName" visible="false"></asp:Label>
</div>
</td>
</tr>
On page load, the textbox is centered properly. but when the visibility of the pNameValidate Label appears, it tries to force both object into the Center.
Is there a way for the textbox to be centered and the label off centered, to the right?
Many thanks for looking.
You can try and add text-align:right; to the style tag in the pName element.
I went with a table and this quickly provided me what I needed...
<tr>
<td>
<table width="100%">
<tr>
<td width="33%"> </td>
<td width="33%">
<div id="shaker">
<input type="text" id="pName" autocomplete="false" clientidmode="Static" name="pName" runat="server" class="pName"
value="Please Enter Your Name Here" onfocus="inputFocus(this)" onblur="inputBlur(this)" />
</div>
</td>
</tr>
</table>
</td>
</tr>
I am working to get a HTML File Upload control in place in a ASPX Web Form page. I have used the below code
<td class="ClientDetailTableLeftColumn">
<asp:Label ID="lblUpload" runat="server" Text="Upload File"></asp:Label>
</td>
<td "ClientDetailTableControls" colspan="2">
<p id="UploadArea">
<input id="FileUploadInput" type="file" size="20"/>
<asp:Button ID="btnUpload" runat="server" Text="Click To Upload" CssClass="btnFormSubmit" />
</p>
<input id="btnUploadMore" type="button" value="Add New Attachment" onclick="AddUploadBox" />
</td>
But while running in Local IIS I am getting an error.
System.Web.UI.HtmlControls.HtmlTableCellCollection must have items of
type System.Web.UI.HtmlControls.HtmlTableCell'. 'p' is of type
System.Web.UI.HtmlControls.HtmlGenericControl'.
The code is failing in the 2nd Line :
Line 85: <td "ClientDetailTableControls" colspan="2">
Line 86: <p id="UploadArea">
Can somebody please help me what could be the resolution to this? Or why is this failing?
Try this
<td class="ClientDetailTableLeftColumn">
<asp:Label ID="lblUpload" runat="server" Text="Upload File"></asp:Label>
</td>
<td "ClientDetailTableControls" colspan="2">
<div id="UploadArea">
<input id="FileUploadInput" type="file" size="20"/>
<asp:Button ID="btnUpload" runat="server" Text="Click To Upload" CssClass="btnFormSubmit" />
</div>
<input id="btnUploadMore" type="button" value="Add New Attachment" onclick="AddUploadBox" />
</td>
<table>
<tr>
<td>
<div style="margin-left: 220px;">
<asp:Button ID="btn1" Text="Edit" CommandArgument='<%#Eval("UserID") %>'
CausesValidation="false" CommandName="Edit" Visible="false" runat="server" />
</td>
</div>
<td>
<div style="margin-left: 370px;">
<asp:Button ID="btn2" Visible="false" Text="Edit" CommandArgument='<%#Eval("UserID") %>'
CausesValidation="false" CommandName="Edit" runat="server" />
</div>
</td>
</tr>
</table>
The problem is when both buttons are made visible dynamically..the second button shifts right wards..how do I fix their position so they appear exactly where I want them ?
[edit]
Do I need to use span or something instead of those divs ? IS there an HTML property that lets u fix a position of an element on page ? How do u do it ? I hv been googling but nothing came up..plz help
[edit 2]
I just added position:fixed in style attribute in the two buttons..when I ran the code again..both buttons didn't even appear!
how do u do it if not even this way ?
[edit 3]
I removed the divs and set both "td's" align property to centre..now the edit buttons are both appearing on the left together :/
Set a fixed width on the columns.
Also you need to fix the ordering of your td and div tags
<table>
<tr>
<td width="200px">
<asp:Button ID="btn1" Text="Edit" CommandArgument='<%#Eval("UserID") %>' CausesValidation="false" CommandName="Edit" Visible="false" runat="server" />
</td>
<td width="200px">
<asp:Button ID="btn2" Visible="false" Text="Edit" CommandArgument='<%#Eval("UserID") %>' CausesValidation="false" CommandName="Edit" runat="server" />
</td>
</tr>
</table>
Will make the column 200px wide, just replace it with whatever width that suits your needs.
Edit:
And well you don't really need the div tags for what you are doing.