понеділок, 30 травня 2011 р.

Some w3s css rules

background: #f00 url(background.gif) no-repeat fixed 0 0;
// по W3C: цвет картинка повторение аттачмент координаты

font: italic small-caps bold 1em/140% "Lucida Grande",sans-serif;
// по W3C: style variant weight size/line-height family

середу, 25 травня 2011 р.

Default ASP.NET Membership Provider Settings

Code to view settings:

protected void Page_Load(object sender, EventArgs e)
{
var type = typeof(Membership);

var infos = type.GetProperties(BindingFlags.Public | BindingFlags.Static);

foreach (var p in infos)
{
PrintProp(p);
}
}

private void PrintProp(PropertyInfo p)
{
var value = p.GetValue(null, null);

Response.Write(string.Format("<b>{0}</b>: {1}<br />", p.Name, value));
}


Result:

EnablePasswordRetrieval: False
EnablePasswordReset: True
RequiresQuestionAndAnswer: True
UserIsOnlineTimeWindow: 15
Providers: System.Web.Security.MembershipProviderCollection
Provider: System.Web.Security.SqlMembershipProvider
HashAlgorithmType: HMACSHA256
MaxInvalidPasswordAttempts: 5
PasswordAttemptWindow: 10
MinRequiredPasswordLength: 7
MinRequiredNonAlphanumericCharacters: 1
PasswordStrengthRegularExpression:
ApplicationName: /

and from machine.config

requiresUniqueEmail: false

суботу, 21 травня 2011 р.

Use the ref config option in ExtJS


var win = new Ext.Window({
layout: 'fit',
width: 300,
height: 200,
title: 'my window',
items: [{
ref: 'panel',
xtype: 'panel', layout: 'form',
frame: true, defaults: {xtype: 'textfield'},
items: [
{ref: '../nameField', fieldLabel: 'Name'},
{ref: 'age', fieldLabel: 'Age'}
]
}]
});

win.show();
//so now, with the above ref options, you can do:
win.nameField.setValue('name here');
win.panel.age.setValue(20);

source

Неплохой css reset


html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote,
pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd,
q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
border: 0 none;
font-family: inherit;
font-size: 100%;
font-style: inherit;
font-weight: inherit;
margin: 0;
outline: 0 none;
padding: 0;
text-decoration: none;
vertical-align: baseline;
}

пʼятницю, 20 травня 2011 р.

Base64 Helpers


public static string ToBase64(this string input)
{
if(string.IsNullOrEmpty(input)) return input;

return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(input));
}

public static string FromBase64(this string input)
{
if(string.IsNullOrEmpty(input)) return input;

return System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(input));
}

Use:

var a = "input";
var b = a.ToBase64();
var c = b.FromBase64();

середу, 4 травня 2011 р.

Webmoney merchant form

On page:
<asp:Content ID="content" ContentPlaceHolderID="afterform" runat="server">
<uc:WebMoneyForm id="wmpay" runat="server" />
</asp:Content>
In code:
wmpay.Amount = 1.5;
wmpay.Description = "некий товар";
wmpay.OrderID = 1001;
wmpay.Purse = "Uxxxxxxxxxxxx";
wmpay.TestMode = true;


public class WebMoneyForm : System.Web.UI.Control
{
public string Action { get; set; }
public string Method { get; set; }
public double Amount { get; set; }
public string Description { get; set; }
public bool TestMode { get; set; }
public int OrderID { get; set; }
public string Purse { get; set; }

public Dictionary Params { get; private set; }

public WebMoneyForm()
{
Method = "post";
Action = "https://merchant.webmoney.ru/lmi/payment.asp";

Params = new Dictionary<string, string>();
}

public void AppParam(string name, string value)
{
if(Params.ContainsKey(name))
{
Params[name] = value;
}
else
{
Params.Add(name, value);
}
}

protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
writer.AddAttribute("id", ID);
writer.AddAttribute("name", ID);
writer.AddAttribute("action", Action);
writer.AddAttribute("method", Method);
writer.RenderBeginTag(HtmlTextWriterTag.Form);

AppParam("LMI_PAYMENT_AMOUNT", Math.Round(Amount, 2).ToString());
AppParam("LMI_PAYMENT_DESC_BASE64", Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Description)));

AppParam("LMI_PAYMENT_NO", OrderID.ToString());
AppParam("LMI_PAYEE_PURSE", Purse);

if(TestMode) AppParam("LMI_SIM_MODE", "0");

foreach(var item in Params)
{
AddHidden(writer, item.Key, item.Value);
}

writer.RenderEndTag();
}

private void AddHidden(System.Web.UI.HtmlTextWriter writer, string name, string value)
{
writer.Write(string.Format("<input type='hidden' name='{0}' value='{1}' />\n", name, value));
}
}