I am trying to style a web page which is created by .net. So I am having issues on some buttons and other elements. My main issue is the bottons because in design template some circle buttons etc are used but .Net keeps giving <input> elements :(
Using <asp:Button> creates <input> element but what should I use to get a <button> element? Because I cannot apply the styles to an <input> element.
I have asked the code for the page, I did not code this so I do not know if it is MVC or not. All I need is to get a ... in the rendered HTML. What can I say to my coder friend so that he makes this work?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Portall.Admin.Login" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Login</title>
<link href="../css/style.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<div class="dvMainContainer">
<div class="header" >
<span>Login</span>
</div>
<div class="dvLoginInfo">
<table>
<tr>
<td>Username</td>
<td>
<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Password</td>
<td>
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td></td>
<td><asp:Button ID="cmdLogin" runat="server" Text="Login" OnClick="cmdLogin_Click" /></td>
</tr>
<tr>
<td colspan="2"><asp:Label ID="lblInfo" runat="server" ForeColor="Red"></asp:Label></td>
</tr>
</table>
</div>
</div>
</form>
</body>
</html>
Code behind file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Portall.Admin
{
public partial class Login : System.Web.UI.Page
{
AdminBL.AdminBusinessLayer adminBsLayer = new AdminBL.AdminBusinessLayer();
protected void Page_Load(object sender, EventArgs e)
{
lblInfo.Text = string.Empty;
}
protected void cmdLogin_Click(object sender, EventArgs e)
{
AdminUser currentUser = null;
try
{
currentUser = adminBsLayer.Login(txtUserName.Text, txtPassword.Text);
}
catch
{
lblInfo.Text = "A database problem occured.";
return;
}
if (currentUser.UserId <= 0)
{
lblInfo.Text = "Invalid username or password.";
return;
}
Session["AdminUser"] = currentUser;
Response.Redirect("UserEntry.aspx");
}
}
}
<asp:Button>with plain HTML<button>? You'll bypass default ASP.NET renderer for buttons but everything else will still work (just remember to update events, for exampleOnClickisonserverclick).<button id="cmdLogin" runat="server" onserverclick="cmdLogin_Click">Login</button>. ASP.NET should wrap that for you in a server object (I'm not sure if it'll useasp:Buttonor a simpleasp:Literal...)