my.net

My Photo
Name:
Location: United States

Tuesday, April 25, 2006

ignore validations on cancel

If you want to make button that should ignore all validations (like a
"Cancel" button), set the "CausesValidation" property of that button to
"false".

short-cuts in vs.net 2003

F7 : code view
shift+ F7 : design view
ctl+ - : move to prev edit point
ctl+ shift+ - : forward edit point
ctl+ alt+ I : immediate window

web service failed with 401

The request failed with HTTP status 401: Access Denied

http://support.microsoft.com/kb/811318/en-us


//Assigning DefaultCredentials to the Credentials property
//of the Web service client proxy (myProxy).
myProxy.Credentials= System.Net.CredentialCache.DefaultCredentials;

setfocus (control) in asp.net

The code below shows a static method that can be used to easily set focus to a control.


public static void SetFocus(Control control)
{
StringBuilder sb = new StringBuilder();

sb.Append("\r\n<script language='JavaScript'>\r\n");
sb.Append("<!--\r\n");
sb.Append("function SetFocus()\r\n");
sb.Append("{\r\n");
sb.Append("\tdocument.");

Control p = control.Parent;
while (!(p is System.Web.UI.HtmlControls.HtmlForm)) p = p.Parent;

sb.Append(p.ClientID);
sb.Append("['");
sb.Append(control.UniqueID);
sb.Append("'].focus();\r\n");
sb.Append("}\r\n");
sb.Append("window.onload = SetFocus;\r\n");
sb.Append("// -->\r\n");
sb.Append("</script>");

control.Page.RegisterClientScriptBlock("SetFocus", sb.ToString());
}