Added LabelTextBox control which renders a textbox with a label contained inside.

This commit is contained in:
Greg Edwards
2015-01-23 21:13:53 -05:00
parent 667bd29c80
commit 5f611534bf
6 changed files with 166 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LabelTextBox.ascx.cs" Inherits="PkmnFoundations.GTS.controls.LabelTextBox" %>
<%@ Register TagPrefix="pf" Namespace="PkmnFoundations.Web" Assembly="PkmnFoundations.GTS" %>
<pf:RequireCss Key="form" CssUrl="~/css/form.css" runat="server" />
<pf:RequireScript Key="jquery" ScriptUrl="~/script/jquery-1.11.1.min.js" runat="server" />
<pf:RequireScript Key="form" ScriptUrl="~/script/form.js" runat="server" />
<div class="pfLabelTextBox">
<asp:Label ID="theLabel" AssociatedControlID="theTextBox" runat="server" />
<asp:TextBox ID="theTextBox" runat="server" />
</div>

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PkmnFoundations.GTS.controls
{
public partial class LabelTextBox : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public String Text
{
get
{
return theTextBox.Text;
}
set
{
theTextBox.Text = value;
}
}
public String Label
{
get
{
return theLabel.Text;
}
set
{
theLabel.Text = value;
}
}
public TextBoxMode TextMode
{
get
{
return theTextBox.TextMode;
}
set
{
theTextBox.TextMode = value;
}
}
}
}

View File

@@ -0,0 +1,33 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PkmnFoundations.GTS.controls {
public partial class LabelTextBox {
/// <summary>
/// theLabel control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label theLabel;
/// <summary>
/// theTextBox control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.TextBox theTextBox;
}
}

46
gts/css/form.css Normal file
View File

@@ -0,0 +1,46 @@
input[type=text], input[type=password], select, textarea
{
display: block;
border: 1px solid #999999;
background-color: white;
box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1) inset;
width: 200px;
height: 14px;
padding: 2px;
font-size: 10pt;
font-family: Arial,Helvetica,sans-serif;
}
input[type=text]:focus, input[type=password]:focus, select, textarea:focus,
input[type=text]:focus, input[type=password]:focus, select, textarea:focus
{
}
.pfLabelTextBox
{
position: relative;
font-family: Arial,Helvetica,sans-serif
}
.pfLabelTextBox label
{
display: block;
height: 0;
overflow: visible;
position: relative;
top: 2px; left: 3px;
color: #cccccc;
}
.pfLabelTextBox input
{
display: block;
background-color: transparent;
position: relative;
}
.pfLabelTextBox input:focus, .pfLabelTextBox input.hasContent
{
background-color: white;
}

View File

@@ -79,6 +79,8 @@
<Content Include="admin\AddBoxes.aspx" />
<Content Include="admin\AddMusical.aspx" />
<Content Include="admin\Sessions.aspx" />
<Content Include="controls\LabelTextBox.ascx" />
<Content Include="css\form.css" />
<Content Include="favicon.ico" />
<Content Include="gts\Default.aspx" />
<Content Include="battlevideo\Default.aspx" />
@@ -3462,6 +3464,7 @@
<Content Include="images\pkmn-sm\99.png" />
<Content Include="RoomLeaders.aspx" />
<Content Include="script\jquery-1.11.1.min.js" />
<Content Include="script\form.js" />
<Content Include="script\retina.js" />
<Content Include="test\BoxUp.aspx" />
<Content Include="test\NameDecode.aspx" />
@@ -3516,6 +3519,13 @@
<Compile Include="admin\Sessions.aspx.designer.cs">
<DependentUpon>Sessions.aspx</DependentUpon>
</Compile>
<Compile Include="controls\LabelTextBox.ascx.cs">
<DependentUpon>LabelTextBox.ascx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="controls\LabelTextBox.ascx.designer.cs">
<DependentUpon>LabelTextBox.ascx</DependentUpon>
</Compile>
<Compile Include="gts\Default.aspx.cs">
<DependentUpon>Default.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>

13
gts/script/form.js Normal file
View File

@@ -0,0 +1,13 @@
function labelTextBox_Change()
{
if (this.value.length > 0)
$(this).addClass("hasContent");
else
$(this).removeClass("hasContent");
}
$(document).ready(function ()
{
$("input").change(labelTextBox_Change);
$("input").each(labelTextBox_Change);
})