Wednesday, June 6, 2012
“click here to reload the designer” message when creating new SL application in Visual Studio 2010
Generally Visual Studio 2010 doesn't come with Silverlight 4 . They have Silverlight 3 capability only.
If you want to develop Silverlight 4 app in any of the above two IDEs, you need to install additional add-on that can be installed from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=b3deb194-ca86-4fb6-a716-b67c2604a139 (34 MB).
Once you have installed, you should start developing Silverlight 4 app.
But when you get the error message “click here to reload the designer” message with the Details pane referring to a null reference exception "object reference not set to an instance of an object"
Just uninstall all the Silver Light named programs from Control Panel.
And follow the process mentioned above .
Don't try to install SilverlightDeveloper.exe before installing SilverlightTools.exe because results in the above error.
Hope this helps!
Thursday, May 31, 2012
Triggers in Updatepanel [AJAX]
The
The ContentTemplate tag is mandatory one,since it holds the content of the panel. The content can be anything that you would normally put on your page, from literal text to web controls.
The Triggers tag allows you to define certain triggers which will make the panel update it's content.
Here is an example which uses both childtags.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>UpdatePanel</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel runat="server" id="UpdatePanel" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger controlid="UpdateButton2" eventname="Click" />
</Triggers>
<ContentTemplate>
<asp:Label runat="server" id="DateTimeLabel1" />
<asp:Button runat="server" id="UpdateButton1" onclick="UpdateButton_Click" text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" id="UpdatePanel1" updatemode="Conditional">
<ContentTemplate>
<asp:Label runat="server" id="DateTimeLabel2" />
<asp:Button runat="server" id="UpdateButton2" onclick="UpdateButton_Click" text="Update" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Build the application and click the two buttons.
protected void UpdateButton_Click(object sender, EventArgs e)
{
DateTimeLabel1.Text = DateTime.Now.ToString();
DateTimeLabel2.Text = DateTime.Now.ToString();
}
You will notice that then first button updates only the first datestamp, while the second button updates both.
If you observe clearly the two buttons are placed in two update panels.
So First button in updatepanel 1 updates first timestamp.
Whereas second button in updatepanel2 updates both because the second update button is referred from first updatepanel using trigger tag.
As you can see, the first UpdatePanel carries a trigger which references the second button.
This will ensure that the first panel is updated even when a control on a different UpdatePanel is used.
The AsyncPostBackTrigger tag is pretty simple - it only takes two attributes
1.controlid, a reference to the control which can trigger it,
2.eventname, which tells which eventtype can cause the trigger to fire.
If you wish for the content of a UpdatePanel to be updated no matter what, you may change the updatemode property to Always.
Thursday, May 24, 2012
Open project created in VS 2010 to 2008
For
Open the solution file in your favorite text editor (example: Notepad++).
Find the following:
Microsoft Visual Studio Solution File, Format Version 11.00.
# Visual Studio 2010.
Replace with:
Microsoft Visual Studio Solution File, Format Version 10.00. (I)
# Visual Studio 2008. (II, optional)
For
Open project file in your favorite text editor (example: Notepad++).
Find the following:
Replace with:
That's it.
Now you can open your solution file on VS2008.
Reverse of this will enable VS2008 solution to open in VS2010.
EDIT
After these changes, you may receive the below error:
---------------------------
Microsoft Visual Studio
---------------------------
Unable to read the project file 'XXX.csproj'.
C:\Project path\XXX.csproj(89,11): The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found.
Confirm that the path in thedeclaration is correct, and that the file exists on disk.
---------------------------
OK Cancel
---------------------------
To fix this error, just change the VS version(v10.0 to v9.0) in your
Wednesday, May 16, 2012
Box Selection and Multi-Line Editing with VS 2010
Box selection is a feature that has been in Visual Studio for awhile (although not many people knew about it). It allows you to select a rectangular region of text within the code editor by holding down the Alt key while selecting the text region with the mouse. With VS 2008 you could then copy or delete the selected text.
VS 2010 now enables several more capabilities with box selection including:
Text Insertion: Typing with box selection now allows you to insert new text into every selected line
Paste/Replace: You can now paste the contents of one box selection into another and have the content flow correctly
Zero-Length Boxes: You can now make a vertical selection zero characters wide to create a multi-line insert point for new or copied text
These capabilities can be very useful in a variety of scenarios. Some example scenarios: change access modifiers (private->public), adding comments to multiple lines, setting fields, or grouping multiple statements together.
Friday, April 20, 2012
copy code and line numbers in visual studio 2010
There is an addon supported in visual studio to copy syntax highlighting and line numbers .Download it from the link http://copysourceashtml.codeplex.com/
It is version for VS2008 ,you need to make some changes to support VS2010.
Download latest CopySourceAsHtml msi and install it
1.By default it will be installed to C:\Users\<username>\My Documents\Visual Studio 2008\Addins
2.Create a folder named Addins under C:\Users\<username>\My Documents\Visual Studio 2010 and copy CopySourceAsHtml.AddIn here.
3.Modify Line #5 and #9 change <Version>9.0</Version> to<Version>10.0</Version>
4.Launch Visual Studio 2010 –> Tools –> Addin Manager, if you see CopySourceAsHtml shows up, then it’s enabled successfully.
6.Now you can select the code and get html by clicking Copy As Html
This is an example. CopySourceAsHtml also provides options to show/hide control line number, word wrap and so on.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace HelloWorld
7 {
8 class Program
9 {
10 static void Main(string[] args)
11 {
12 // My first application
13 System.Console.WriteLine(“Hello, World!”);
14 }
15 }