phone user control

we developed a nice easy-to-custom UC for phone with prefix:

i must say that the MyForm:TextBoxField are custom WebControls that renders like this:
<span>
    <label>
    <input>
    <validator>
    <validator>
    ...
<span>

so aspx/html is

<div id="IecPhoneField" class="PhoneField" runat="server">

   <MyForm:TextBoxField ID="txtFullPhone" Required="True" CssClass="PhoneFieldPhone" ValidationType="Phone" runat="server" RequiredError="required" />

   <span class="makaf">-</span>

   <MyForm:TextBoxField runat="server" ID="PhonePrefix" CssClass="PhoneFieldPrefix" ValidationType="RegExp" FormatError="יש למלא קידומת תקנית" RegExp="^(0[0-9]{1,2})$" Required="true" MaxLength="3"/>

</div>

and cs is

public partial class PhoneField : UserControl
{
 
public string ValidationGroup
  {
 
  get { return (string)ViewState["ValidationGroup"]; }
    set { ViewState["ValidationGroup"] = value; }
  }
 

  public string CssClass
  {
 
  get { return (string)ViewState["CssClass"]; }
    set { ViewState["CssClass"] = value; }
  }
 

  public string Label
  {
 
  get { return (string)ViewState["Label"]; }
    set { ViewState["Label"] = value; }
  }


 
public string Prefix { get { return txtPhonePrefix.Text; } }

  public string Phone { get { return txtFullPhone.Text; } }

  protected void Page_Load(object sender, EventArgs e)
  {
 
  if (!string.IsNullOrEmpty(CssClass))
    PhoneField.Attributes["class"] = PhoneField.Attributes["class"] + " " + CssClass;
    if (!string.IsNullOrEmpty(ValidationGroup))
      txtFullPhone.ValidationGroup = txtPhonePrefix.ValidationGroup = ValidationGroup;
   
if (!string.IsNullOrEmpty(Label))
      txtFullPhone.Label = Label;
  }
}
 


is if you want basic CSS

.PhoneField > span { display:table-cell; }

.PhoneField .PhoneFieldPhone label { display:inline-block; width:210px; }

.PhoneField .PhoneFieldPhone { width:400px; margin-left:0; }

.PhoneField .PhoneFieldPrefix input { width:25px; }

.PhoneField .PhoneFieldPhone input { width:170px; }

.PhoneField .makaf { padding-left:13px; padding-right:13px; }
 

Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

Asp.Net Ending Response options, Response.End() vs CompleteRequest()

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem