Reputation: 391
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");
}
}
}
Upvotes: 3
Views: 2866
Reputation: 9591
Download CSSFriendyControlAdapters and use it to create a button server control. You can find it here:
http://cssfriendly.codeplex.com/
Just take a look at the simplest control and it should be easy enough to modify it to emit a button. You don't have to change your existing controls, it will use you adapter instead.
If you don't care about having too much control and rendering options, you can simply use the built-in HTMLButton control:
<tr>
<td>
<button ID="cmdLogin" runat="server" OnServerClick="cmdLogin_Click">
Login
</button>
</td>
</tr>
Upvotes: 3
Reputation: 391
Using <asp:ImageButton />
lets me to add any styling I need, i.e. background image, gradients etc.
For more information on using reffer to Microsoft site
Upvotes: 1