- (tools) (options) under (environment) (fonts and colors)
- show settings for (text editor)
- under (display options)
- Highlight Reference is the one you want
- Change it, maybe restart vs 2010 for good luck.
Tuesday, 11 December 2012
Highlight color for matched word in visual studio
Monday, 10 December 2012
When to use Partial Class?
Fundamentals of partial classes
A partial class allows a single class to be divided into two separate physical files. During compile time, these files get compiled into a single class. For instance, you can see in the below figure we have the customer class divided into two different files “customer1.cs” and “customer2.cs”.
During compilation, these files get compiled into a single class internally. So when you create an object of the
Customer
class, you will be able to see methods lying in both the physical files. For instance, you can see the Add
method belongs to customer1.cs and the Delete
method belongs to customer2.cs, but when the Customer
object is created, we can see both the Add
and Delete
methods.Fundamentals of partial methods
There is one more important concept in partial classes called partial methods. Partial methods helps us to define a method in one physical file and we can implement that method in another physical file, as shown in the below figure.
In the figure, you can see we have defined the
Validate
method in Customer1.cs and this Validate
method is implemented in Customer2.cs. Please note the partial
keywords attached to both of these methods.
l
Thursday, 22 November 2012
How to create Solution file in VS 2010
When you build the website it will ask you an option to save the .sln file then you can save it inside your website. If saving opening does not appear when you build then you can find this file inside..
go to dis path C:\Documents and Settings\admin\My Documents\Visual Studio 2010\Projects. Here you can find you website name and fild you .sln file in that website. you can cut and paste that .sln in your website. Now you can run ur website by click on solution file..
- Create a new solution (1 directory level above the project is convenient).
- Then use "Add existing Items" and multi-select all files you want to add. You can do this in several steps. Add references that are missing.
- Create New Folder and rename to--> App_Code
- Now you can import all the class file here
Creating a Simple Auto-Complete TextBox ASP.NET
Resources: http://www.asp.net/ajaxlibrary/act_AutoComplete_Simple.ashx
Creating a Simple Auto-Complete TextBox
In this tutorial, you learn how to apply an AutoCompleteExtender control to a TextBox in order to display auto-complete suggestions as you type.
We'll create an auto-complete TextBox by following these steps (1) Add a ToolkitScriptManager (2) Add a TextBox control (3) Add an AutoCompleteExtender (4) Add a page method.
To learn how to install the Ajax Control Toolkit, see the Ajax Control Toolkit page.
Next, change the ID of the TextBox control to txtMovie. You can change the ID in the Properties Window. The resulting source code looks like this:
The easiest way to add the static page method is to click on the Add AutoComplete page method smart tag option. Selecting this menu option will create a new page method named GetCompletionList:
VB
C#
Notice that this method is passed parameters which represent what the user has typed into the TextBox (prefixText) and the number of auto-complete suggestions to show (count).
The following GetCompletionList() method returns a matching movie from a list of movies:
VB
C#
The following TextBox illustrates how the AutoCompleteExtender works. Enter the text Star into the TextBox and you will get matching suggestions.
We'll create an auto-complete TextBox by following these steps (1) Add a ToolkitScriptManager (2) Add a TextBox control (3) Add an AutoCompleteExtender (4) Add a page method.
To learn how to install the Ajax Control Toolkit, see the Ajax Control Toolkit page.
Add a ToolkitScriptManager
Before you can use any of the Ajax Control Toolkit controls in a page, you first need to add a ToolkitScriptManager to the page. You can drag the ToolkitScriptManager from the Visual Studio Toolbox window onto the page. The ToolkitScriptManager is located in theAjax Control Toolkit tab under the Toolbox.- <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
- </asp:ToolkitScriptManager>
Add a TextBox Control
The AutoCompleteExtender works with a standard ASP.NET TextBox control. In Design view, drag a TextBox control from under the Standard tab in the Toolbox onto your page.Next, change the ID of the TextBox control to txtMovie. You can change the ID in the Properties Window. The resulting source code looks like this:
- <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
- </asp:ToolkitScriptManager>
- <asp:TextBox ID="txtMovie" runat="server"></asp:TextBox>
Add an AutoCompleteExtender
The next step is to apply an AutoCompleteExtender control to the TextBox. Add the following AutoCompleteExtender control to your page:- <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
- </asp:ToolkitScriptManager>
- <asp:TextBox ID="txtMovie" runat="server"></asp:TextBox>
- <asp:AutoCompleteExtender
- ID="AutoCompleteExtender1"
- TargetControlID="txtMovie"
- runat="server" />
Add a Page Method
The final step is to create a method that returns the auto-complete suggestions. You can return auto-complete suggestions from an ASMX Web service, a WCF Web service, or a static page method. We use a static page method.The easiest way to add the static page method is to click on the Add AutoComplete page method smart tag option. Selecting this menu option will create a new page method named GetCompletionList:
VB
- <System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()>
- Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
- Return Nothing
- End Function
C#
- [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
- public static string[] GetCompletionList(string prefixText, int count, string contextKey) {
- return default(string[]);
- }
Notice that this method is passed parameters which represent what the user has typed into the TextBox (prefixText) and the number of auto-complete suggestions to show (count).
The following GetCompletionList() method returns a matching movie from a list of movies:
VB
- <System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()>
- Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
- ' Create array of movies
- Dim movies() As String = {"Star Wars", "Star Trek", "Superman", "Memento", "Shrek", "Shrek II"}
- ' Return matching movies
- Return (
- From m In movies
- Where m.StartsWith(prefixText,StringComparison.CurrentCultureIgnoreCase)
- Select m).Take(count).ToArray()
- End Function
C#
- [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
- public static string[] GetCompletionList(string prefixText, int count, string contextKey) {
- // Create array of movies
- string[] movies = {"Star Wars", "Star Trek", "Superman", "Memento", "Shrek", "Shrek II"};
- // Return matching movies
- return (from m in movies where m.StartsWith(prefixText,StringComparison.CurrentCultureIgnoreCase) select m).Take(count).ToArray();
- }
The following TextBox illustrates how the AutoCompleteExtender works. Enter the text Star into the TextBox and you will get matching suggestions.
Subscribe to:
Posts (Atom)