Search Results
ASP.Net C#.Net
Description: This article mentions some of the details of moving .Net code to a *Nix machine (NEW) Mono allows you to run .Net code on *Nix machines.  Some links are below http://www.mono-project.com/Roadmap
Description:  This topic discusses the basics of delegates. Basics Try to think of delegates in these terms.  Although not exact, they can help you wrap your head around them if you're new.  If you're not new to delegates, then the more advanced stuff will be near the end of the topic. ...
What are generics?  An easy name for parametric polymorphism that refer to classes and methods that work homogeneously on values of different types.  The code of this type of data structure remains the same; though, the data type of the parameters can change with each use.  Basically, a generic is a code template that can be used over and over with different data types.Why use them?&nbs...
C# - VB.Net Method Implementation using System; public interface IAVDevice { IAudio GetAudio(); IVideo GetVideo(); } public interface IVideo { string GetPictureQuality(); } ...
A common use of graphics is for advertisements - most Internet ads are stored as .gif files. Visual Studio includes the AdRotator control to handle the tasks associated with displaying these types of ads...
Description: This topic will show you how to add the NicEdit inline content editor to your ASP.Net web application and allow your Server Side code to access the editable content. Notes: You will need to download the current version of NicEdit at nicEdit.comAlso, if you are going to use the code changes recommended in the nicEdit.js file, I am requiring th...
Description: This tutorial will show you how to add themes to a web application to manage different browsers with CSS Notes: (none) Open your web application and perform the following steps Right click on the Web Application Project in the Solution Explorer and select "Add ASP.Net Folder > Theme" and call the folder anything you would like (E.g. "InternetExplorer")&n...
The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside an
Datagrid and State   If you fill a data set and bind the data to the DataGrid control in the Page_Load
Description: This topic will show you how to bind a Generic List to a dropdownlist First you must have a class that you will use in your Generic List.  Below is an example [Serializable] public class Topi...
Description: This article will show you how to bind a XLINQ Query to any datasource bindable control (e.g. DropDownList, CheckBoxList, RadioButtonList, ListBox)    LINQ to XML uses the
[Serailiazable()] public class MyClass {    public enum SortDirection    {       ASC = 0,       DESC = 1 ...
Cashing   1. Remember that ASP.NET throws away Web form variables after the form is displayed, so you'll want to save data sets ...
Calendar control   To get or set dates selected on the Calendar control, use the "SelectionChanged" event procedure and the "SelectedDate&qu...
Description: This article will show you how to use a Parent Page with a Child Page.  The Child Page will call the Parent pages javascript method that will inturn call a server side method to perform updates on the page.  The server-side method is triggered by the button click event of a button within an update panel.  A popup is called from the parent page. 1.  In the markup of the ...
C# - Character Delimiting an Array   private void RebuildTable()
C# CHECKBOXLIST or RadioButtonList   To get or set the values from a CheckBoxList or RadioButtonList control, use a For Each loop to check each control in ...
1. Add a CheckListBox to your ASP.Net page 2. In the Page_Load method, add the following code:         ...
Response.Write("<script language='javascript'> { self.close() }</script>"); ...
COMPOSITION   The "has-a" relationship defines composition  
CONTROL ForEach to clear value   void ClearTextBoxes()
Description: This tutorial will show you how to convert an ASP.Net Web application to use the Microsoft MVC Framework. Notes: 1.
C# Create a SQL Db connection in code with update, insert, and delete capability   1. MAKE SURE YOU ADD THE FOLLOWING CLASSES
If you'd like to add an icon that shows up in IE 5.x or higher. 1.  Create a 16 by 16 pixel icon. 2.  Name the icon "favicon.ico" 3.  Place the file in your web's root folder. 4.  To test, open the page from your hosted server and add to "Favorites"
Creating a Subweb To add the FrontPage Server Extensions to a virtual folder, follow these steps:   ...
Cursor Cursor.Current = Cursors.WaitCursor; Cursor.Current = Cursors.Default; ...
C# DATABASE - ISOLATION LEVELS   ISOLATIONLEVEL     BEHAVIOR
Database Savepoints   NOTE: Use this help file with the "TRANSACTIONS - Database - Deleting records" help file
C# Datagrids and SQL DataTypes   1. When you set AutoGenerateColumns=True, DataGrid internally creates a collection of autogenerated columns. If the data type
C# DATAGRID Deleting a row   1. Create a connection, data adapter, dataset, and a datagrid like you would normally do
Description: This topic will show you how to use LINQ to sort a datagrid in an ASP.Net page.Notes: We will assume that you know how to put a datagrid on your page.  We are also assumming that you have a custom object that you are binding to the datagrid. First we are going to create two Session Properties to keep the SortExpressions value and the Object Collection fro...
DataGrid, DataList, Repeater Controls   ADDING ITEMS TO DATAGRID, DATALIST, and REPEATER CONTROLS &n...
Datagrids and SQL DataTypes   1. When you set AutoGenerateColumns=True, DataGrid internally creates a collection of autogenerated col...
<%@ Page Language="C#" %> <html>    <body>       <br/>       <h2>The date and time is <% =DateTime.Now.ToString()%>.</h2>    </body> </html> ...
1.  Go to Tools | Options 2.  Click on Debugging | General 3.  Check the "Rediriect all Output Window text to the Immediate Window" ...
Scenario: Application calls Windows Service   The Main Application's configuration file must be changed. You must change
1.  First you need to enable your browser's script debugging      a.  From IE, go to "Tools | Internet Options"      b.  Click the "Advanced" tab.      c.  Under the "Browsing" category, clear the "Disable Script Debugging" checkbox. ...
Description: These are simple examples to show you how to use TryParse Parameterss          Type:
Description:  Sometimes if you have multiple buttons on your page and you click "Enter", the button that you want to run, doesn't execute. A quick way to handle this is to set the tab order of the input controls.  Set the button' tab Index to 0 or lower than all of the other input controls and it will fire first when you hit t...
Description: This topic shows you how to detect mobile devices from an ASP.Net web site. Notes: The IsMobileDevice property on the Request.Browswer object is unreliable, so I would use it. Below is a method to help you determine if the device calling your page is mobile.
Abstract This white paper discusses the differences in syntax between the Microsoft® Visual Basic .NET™ and Microsoft® Visual C# .NET™ programming languages. Visual Basic...
Description: This topic shows you how to disable processing of a button during processing. Notes: This is best implemented in an UpdatePanel. Add the following "OnClientClick" to your ASP:Button markup: OnClientClick
C# DROPDOWN LIST   To display items from a data set in a ListBox, DropDownList, CheckBoxList, or RadioButtonList control, follow these steps: ...
C# DROPDOWN LIST   Executing Commands on a database  
C# DROPDOWN LIST   To display items from a data set in a ListBox, DropDownList, CheckBoxList, or RadioButtonList control, follow these steps: ...
ApplicationName - Common Language Runtime   There might be dll's that are new or needed with the application that are not included.
SYMPTOMS In Microsoft Visual Studio .NET 2003, when you build a Web project that is several levels deeper than the root Web folder, the project does not compile. You may receive an error mess...
The following error occurs:   When trying to compile a .Net application, the following build errors were detected.
C# ExecuteNonQuery   If you are executing the "ExecuteNonQuery" funciton in .Net
The VS7 Debugger doesn’t work. What can I do? By mkpark@microsoft.com <mailto:mkpark@microsoft.com> (Visual CSharp Debugger QA team)  
Error "Login failed for User '(null)'   1. Open up IIS
System.Data.SqlClient.SqlException: Login failed for user 'MachineName\ASPNET'    SQ...
This happens when your SMTP is not configured to your localhost   1. Open IIS
Description: TargetInvocationException can be thrown when trying to deserialize a property that is a double or single datatype when using the SerializationInfo object on a Serialized object. Notes: This is the following set up1.  Remoting is used between the Web Server and a remoting server2.  An Object/DomainObject/Model has a property of type double or single3.  The middle-tier (Re...
1. Make sure debugging is enabled in your web.config 2. Remove all the references 3. Manually d...
HOW DO I EXECUTE A .NET PROJECT FROM A NETWORK SHARE, LAN FILE SERVER, OR INTRANET UNC?   When opening a project on a network drive either Novell or Micros...
1. Introduction   ASP.NET 2.0 brings an important concept called provider model which is used for many new feature i.e. Membership Managem...
The notes below are good to follow, if having more trouble, but initially try the following   1. Refesh your solution
RESOLUTION To work around this problem, use one of the following methods: • For R...
C# - Unable to start debugging   Error while trying to run project: Unable to start debugging on the web server. The project is not configured to be debugg...
v1.1.4322\mscorwks.dll could not be loaded   This is usually caused when you are trying to run a .Net application
C# ExecuteReader   The "ExecuteReader" method performs commands that return records, such as SQL SELECT. Each record is returned as a
ExecuteReader - Calling SQL Parameters   One well-known...
C# ExecuteReader - Calling SQL Parameters   One well-known performance tip when you're working with databases is to move frequently used tasks into stored...
C# - FOREACH ON DATASET   NOTE: 1. Look at DB - Create a connection in code with update on populating the dataset
Description: Shows how to format a string to currency format   decimal myValue = 1921.39m;string output = String.Format("Order Value: {0:C}", myValue );Console.WriteLi...
Formatting a date field   Private Sub FormatMyDate()
Table 1-5. Visual Basic .NET and Visual C# Differences   Feature  Visual Basic .NET                  &n...
C# Getting Files from the Client   Use the File Field HTML control to upload files from the client to the server. The File Field HTML control is actua...
Getting file from the server   The following code shows one way to retrieve the file from the server. In this case, the file is displayed in the brows...
Description: How to get values from Querystring   Example: protected void Page_Load(object
Description:  You can use the guidelines below to help you with setting up a Membership Provider within your web application. 1. First make sure you have the aspnet tables for the providers in your database.  If not, you can follow the steps in this topic
Description: This tutorial shows you how to add two listboxes that you can use to manage a collection.  One might be the collection tied to an object and the other a list that you can choose from to add to your collection.  (e.g. Company Users and user's that are administrators)  These listboxes reside within AJAX update panels.  1.  Add the ...
DESCRIPTION: This tutorial shows you how to create a custom account to run an ASP.Net application VERSION: 1.1 or higher 
DESCRIPTION:  This tutorial uses true n-tier development to connect an ASP.Net web application to a SQL Server Database.  We will build an Object Layer with collections, as well as, a Data Access Layer and a Business Logic Layer.VERSION: 1.1 or higher Database setup
Description: This code allows you to treat radio buttons inside a repeater as a group.  This is needed because Microsoft's repeater control implements the INamingContainer making each control unique.  The GroupName attribute will not work because the unique client naming overrides the use of the GroupName property.  The Javascript below basically unchecks the radio buttons that are not selected...
Description: If you put two <Div> tags horizontally next to each other, you will notice a 3px gap if the one on the left is set to float.  This only happens in IE5 and IE6.   To fix this you can add the following to your CSS file.
DESCRIPTION: This tutorial demonstrates how to implement forms based authentication by using a database to store the users VERSION: 1.1 or higher
DESCRIPTION: This tutorial shows you how to make a website on your machine available with a domain name. VERSION: 1.1 or higher. NOTE: You must have the Windows .NET runtime installed.
Description: Sometimes within an UpdatePanel, you would like to postback the main page.  This may need to be done if you are trying to enable or making something previously hidden visible.  You can accomplish this by using triggers.  By placing triggers on postback controls, you can tell the update panel to perform a synchronous call versus an asynchronous call.To place a trigger within your markup, you add the
Description:  To set up a database to use with any of the providers or ASP 2.0+ or greater controls, you will need to set up the aspnet tables within your database. 1.  Locate the aspnet_regsql.exe file on your computer.  You can find it under [drive:]\%windir%\Microsoft.Net\Framework\version on your web server or on your ...
Description:  This topic discusses how to bind a collection to a repeater.  It will also show you how to get the object back by using a AJAX Hover MenuNotes: (None) 1.  Within your .vb or .cs file, define a collection object and fill it. E.g...   
C# Image Button to calculate where clicked   private void ImageButton1_Click(System.Object sender, System.Web.UI.ImageClickEventArgs e)
ACCESS VB                C#                 &nbs...
WINDOW SERVICES   NOTE: Always close "Services" window after stopping a service,
Description: This code will show you how to implement a timer with Javascript     window.onload...
Description: This topic will show you how to keep the position of a collapsible panel during postbacks.  I have this markup and code in a MasterPage to control the menu's for my site. Notes: (None) Add the following markup to have a collapsible panel on your page
Description: Sample code for populating a Generic Dictionary object with LINQ Notes: You must have a references to the System.Linq and System.Collections.Generic classes. MyObject myObject = someMethodThatPopulatesMyObject();Dictionary<
ListBox   ADDING ITEMS lst_MyBox.Items.Add...
Description: This topic will give you the pieces you need to add an ASP.Net ListView control to your page and how to get the values out of the ListView in code behind Add the update panel and ListView Item to your page.  Notice that the DateKeyNames for the ListView, match the fields I use from the ListItem object that I bind in the Code Behind.
Description: This allows the page to be maximized upon openning the page. Note: Sometimes, if you use the script from the Page_Load method, it will affect CSS.  If this is the case, then put it into the page HTML section.  Do not put it in the Header, try the top of the Body tag Page_Load method
When a person does a mouseover on the link, it shows the panel, which has a table of rules     This wa...
Ways to Navigate   ASP.NET provides five distinct ways to navigate between pages in your application
C# - Navigation - Displaying a Page in a New Browser Window   To start a new instance of the browser, use the client-side "Window" object's "...
most forms use "using System.IO;"   WebForm SignOn
Navigation using Hyperlinks and Redirection   Hyperlink server controls respond to user click events by displaying the page specified in t...
Navigating using the "EXECUTE" method   Use the "Server" object's "Execute" method to process a second Web f...
C# - Navigation using the Transfer method   Using the "Transfer" method is similar to executing a hyperlink or using the "Redirect" met...
ASP.NET PAGE LIFECYCLE   ( taken from http://www.15seconds.com/issue/020102.htm )   STAGE        &nb...
C# Panels   Use the Panel control to group controls on a Web form. Using the Panel control on a Web form is different from using the Panel control
Passing a QueryString to a Frame-IFrame from Code   1. Add a FRAME to your page markup within your body tags
Printing From VBScript allows you to bypass the Print Dialog box   1. You must add the following object in the <head> tags of the markup languag...
Description: The following topic will show you how to call FancyBox programatically. There are some basic things your page will need to have You'll need a ScriptManager on your page You'll need to add the proper links to your js f...
C# CHECKBOXLIST or RadioButtonList   To get or set the values from a CheckBoxList or RadioButtonList control, use a For Each loop to check each control in ...
Radio Buttons NOTE:  You don't have to place RadioButton controls in a panel to get them to work together.  Instead, you enter a name in their "GroupName" property. ...
Description: This script will show you how to catch the device and redirect to a mobile version of your website. Notes: This was taked from the source of the following site: http://www.porsche.com/usa/ Script is shown below
Referencing JavaScript or JScript File in ASP.Net   1. Go to the ASP.Net page you want to add the Script File reference and open the markup ...
Description: When using AJAX and JavaScript, previous JavaScript code that used "getElementByID" may not work with AJAX controls. Notes: (none) In order for your JavaScript to recognize controls contained within AJAX controls, such as UpdatePanel, you need to replace code, such as,This is preferred: var objExtenderma...
Description: If  you you an XSD type Data Access Layer, and have a Dropdownbox that is connected to it using a DataSource Object, you can use the following lines to refresh the dropdownlist. TopicAreaDataSource.Select();ddlTopicArea.DataBind(); ...
Here are some Validation Expressions to use with Regular Expression Controls C# File Naming Convetion
Description: This topic will give you some tips on how to remove flicker associated with a collapsiblepanel if collapsed is set to True.Notes: (None) Situation:  Sometimes when you have a collapsible panel that is set to collapsed (Collapsed = True), you will get a flicker on the page briefly showing you the panel as if it were extended, then it will set itself to the collapsed state....
To reset framework ... c: cd \windows\microsoft.net\framework\v1.1.4322 aspnet_regiis.exe -i iisreset.exe ...
This window allows you to place debug points while in debug mode     VS2003
Description:  Sometimes you will get an error when trying to connect to a secure web server for sending HTTPWebRequests.  The following error will sometimes be generated when this happens: "The remote name could not be resolved: 'www.mywebsite.com' at System.Net.HttpWebRequest.GetRequestStream() at...   To get around ...
ASP.Net - Sending QueryString to Frame/IFrame   1. Go to the markup of the page   ...
Description:  This topic shows you the steps to start up a new site on Ultimahosts, the database, and the source code for MyCredenza.  1.  Register your domain.      - Go to your domain provider and register a domain.      - Change the named servers to ...
Setting visibility of an IFrame-Frame   1. Find Frame tag and add the following attribute to the element
C# Application and Session State   Use the "Application" and "Session" states to store data that you want to keep for the lifetime of a...
Context Handler object   Use this object to retrieve public members of one Web form's class from a subsequently displayed Web form.
SETS A COOKIE (C#) Use this to store small amounts of information specific to a user on their machine. 
Query Strings   Use these strings to pass information between requests and responses as part of the Web Address.
VIEW STATE   Use the ViewState property to save data in a hidden field on a page. Because ViewState stores data on the page, it is limited to
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load           If Request.QueryS...
switch (caseSwitch) {     case 1:         Console.WriteLine("Case 1");         break;     case 2:         Console.WriteLine("Case 2");
C# DATAGRID Deleting a row   1. Create a connection, data adapter, dataset, and a datagrid like you would normally do
TypemockUnit Testing ASP.NET? ASP.NET unit testing has never been this easy.Typemock is launching a new product for ASP.NET developers – the ASP.NET Bundle - and for the launch will be giving out
Description:  If you have an update panel with a validator of any type associated with it, it will cause a postback on the first attempt of the button click, but on subsequent clicks of the button, it will fail to postback to the server. Reason: This is caused by the javascript not allowing the ...
Description: Gives the life cycle of user control and page lifecycle together Default.aspx page with a custom control on it. Here is the log of events: Control: OnInitPage: Page_InitPage: Page_LoadControl: OnLoadPage: Page_PreRenderControl: CreateChildControlsControl: PreRenderControl: SaveViewStateControl: Render Here is what hap...
Note: Needs System.IO Class   Private Function ValidateFile(ByVal theFile...
Canceling Validation   Because validation occurs before the server processes the page, a user can become trapped by validation unless you ...
C# - Creating Validation Controls   RequiredFieldValidator     - Check whether a control contains data
C# Validation - Customizing   To perform complex types of validation not provided by the standard validation control, use a CustomValidator control and wri...
public string ParameterSortType {    get    {       if ( ViewState["ParameterSortType"] == null ) &n...
Basics IIS (Internet Information Services) 1. You need a Virtual Dir...
Using Web.Config file   To set values in the web.Config file and call from application do the following: ...