November 3 2010 by
Ryan Carter in
ASP.NET,
C# |
For some reason I am coding away and inexplicably, usually when trying to update my Subversion repository, the aspx.designer.cs file that is attached to my page simply decides to ignore all my controls. Perhaps a guru who knows why could explain in the comments, and I am just ignorant. I wouldn’t argue that with you. [...]
To set the text, or displayed value of a Label Control in ASP.NET, do this: lblName.Text = "Ryan"; One thing to note is how to name label controls, with a prefix of “lbl” which helps you identify the type of control anywhere in the code. Also, if you are going to be using a variable [...]
This accepts a GUIDW length parameter and will return the random GUID, sans hyphens, ready for appendage to your filename, string, or other random use. Enjoy! Courtesy of 4guysfromrolla.com public string GetRandomPasswordUsingGUID(int length) { // Get the GUID string guidResult = System.Guid.NewGuid().ToString(); // Remove the hyphens guidResult = guidResult.Replace("-", string.Empty); // Make sure [...]
At the top of the .cs file (code behind) you will see a list of using statements, which act almost like includes, and provide functions from the specified file being used. For example, the oft used ArrayList collection object is part of the System.Collections namespace. Without the directive used here below, you won’t be able [...]
To auto-close a datatable after it is done being used (as well as creating a DataTable), a using statement is most helpful. using (DataTable dt = new DataTable()){ //your datatable specific code here }
A dropdown’s SelectedIndex property is the number (int) of the line item selected, 0 for the first, 1 for the second, regardless of data. Example: if(ddlCustomer.SelectedIndex == 0){ Response.Write("Hello World."); }
Response.Write("this is the message");
March 22 2010 by
Ryan Carter in
ASP.NET,
C# |
Response.Redirect("http://www.google.com");