Showing posts with label Visual Studio 2005. Show all posts
Showing posts with label Visual Studio 2005. Show all posts

Thursday, August 16, 2012

Correcting AJAX Calendar Extender Popup Calendar Position

Recently I encountered a positioning error in AJAX calendar extender. When I use the calendar extender inside of other container controls the popup calendar started appearing few inches above the button. You will be able to get an idea of the problem by the following image.

image_thumb

Since I couldn’t get it fixed by changing the properties I thought to find a solution for this.

One way to correct this is by applying a CSS style sheet to change the calendar positioning manually. I found this method while searching the web. This way since you need to enter the location of the calendar you need to try several times to get the correct positioning. If you are using this method simply place the following CSS style in your page and apply the style as shown. Remember you need to change the value to suit your form.

  1. <style type="text/css">
  2.     .fromDtPos
  3.     {
  4.         left: 245px !important;
  5.     }
  6. </style>

Apply the style to your calendar extender.

  1. <cc2:calendarextender id="calExpiry" runat="server" targetcontrolid="txtExpiry"
  2.     format="dd MMM yyyy" popupbuttonid="imgExpiry" enabled="True" cssclass="ajax__calendar fromDtPos">
  3. </cc2:calendarextender>

My preferred way to do this is by using the JavaScript that I wrote below. Since you do not need to enter the position manually this will be easier. Also this code will work irrespective of the number of parent containers it is having above of the control.

Insert the below JavaScript into your page.

  1. <script type="text/javascript" language="javascript">
  2.     function showCalendar(sender, args) {
  3.         var processingControl = $get(sender._button.id); // Getting the control which triggered the calendar.
  4.         sender._popupDiv.parentElement.style.top = processingControl.offsetTop + processingControl.height + 'px';
  5.         sender._popupDiv.parentElement.style.left = processingControl.offsetLeft + 'px';
  6.  
  7.         var positionTop = processingControl.height + processingControl.offsetTop;
  8.         var positionLeft = processingControl.offsetLeft;
  9.         var processingParent;
  10.         var continueLoop = false;
  11.  
  12.         do {
  13.             // If the control has parents continue loop.
  14.             if (processingControl.offsetParent != null) {
  15.                 processingParent = processingControl.offsetParent;
  16.                 positionTop += processingParent.offsetTop;
  17.                 positionLeft += processingParent.offsetLeft;
  18.                 processingControl = processingParent;
  19.                 continueLoop = true;
  20.             }
  21.             else {
  22.                 continueLoop = false;
  23.             }
  24.         } while (continueLoop);
  25.  
  26.         sender._popupDiv.parentElement.style.top = positionTop + 'px';
  27.         sender._popupDiv.parentElement.style.left = positionLeft + 'px';
  28.     }
  29. </script>

Then call the function showCalendar on onClientShown event of the calendar extender as seen below.

  1. <cc2:calendarextender id="calExpiry" runat="server" targetcontrolid="txtExpiry"
  2.     format="dd MMM yyyy" popupbuttonid="imgExpiry" enabled="True" onclientshown="showCalendar">
  3. </cc2:calendarextender>

Both of the above methods will correct the appearance of the popup calendar of the AJAX Calendar Extender as seen below.

image_thumb1

Monday, December 05, 2011

Developing iPhone and Android Applications using C# .Net

Being a .Net developer did you think how great if you could develop applications for most popular mobile device platforms like iPhone and Android with the .Net skills you already have. If you were thinking like me then the wait is over.

Now with Mono you can create cross platform applications using your .Net framework skills. Mono is a software platform using which you can develop applications which runs on iPhones, Android devices, iPads and iPod Touches.

As per the Mono site, “The Mono Project is an open development initiative sponsored by Novell to develop an open source, UNIX version of the Microsoft .NET development platform.” If you are wondering about the name Mono, it is 'monkey' in Spanish.

You can try Mono for free by downloading the trial by going to the trial link. The good thing is after installing Mono you can use the more familiar Visual Studio to do the development using the available Mono templates.

Saturday, December 06, 2008

Visual Studio not Showing Errors

Is your Visual Studio showing error line numbers and respective pages while you develop?
If not read on, recently I came up to a machine which was having Visual Studio error. Visual Studio was showing errors when a project is compiled but the error details (error code line number, error file) which we can use to identify the error are not displayed.
After trying out several things found the cause of it and thought to share it.
The problem was not with the project but with the path the project was kept.
In the machine the failing project was stored under a folder which was having parenthesis or brackets "(".
For example the solution path was like C:\ProjectsA(V1)\MyProj\.
The (V1) part was confusing Visual Studio making it stop displaying the error details.
If you also have the same problem simply remove the brackets by renaming the folder and reload your project to Visual Studio from the new path. The error details will be shown correctly.

Monday, August 11, 2008

HTML Meta Tags

Do you know what can be done with HTML Meta tags?
If not then you will also struggle when trying to do a page refresh or a redirect.
To get more details on how to please refer the following web site.
http://webdesign.about.com/od/metataglibraries/a/aa080300a.htm

Thursday, July 31, 2008

Implementing a File Download in ASP.NET

Recently I gave some help to a colleague of mine implementing a file download. So I thought of sharing it with you.
If you need to make a web site user to download a file from your site you have to use HTTPResponse.Page.Response object. By using this you will be able to make the user download numerous kinds of files to their machines. The code required is as follows.

// This defines the type of the file that you are allowing to download.
Response.ContentType = "application/vnd.ms-excel";
// Path to the file to be downloaded.
string FilePath = MapPath("Xcel.xlsx");
// Initiating the file download.
Response.WriteFile(FilePath);
Response.End();

The above code will let the user download an Excel file named Xcel. Aprt from Excel you can use other file types as well by changin the Response.ContentType to the required file type.
A list of available content types are as follows.

Friday, January 04, 2008

Inserting a Double Quote in to a String in .NET

Even though this is not new I do forget this always, so thought of putting an entry on how we can put a double quote inside of a string.

VB.NET
Dim str As String = "Example String " & """" & "This is the String with double quotes." & """"
MessageBox.Show(str)

In VB.Net you can indicate that there is a double quote in a string by using 4 double quotes ("""").

C#.NET
string str = "Example String " + "\"" + "This is the String with double quotes." + "\"";
MessageBox.Show(str);

As you will notice in C# the double quote can be represented as double quote, back slash and again using two double quotes ("\"").

The above string will be displayed as follows.

image

Tuesday, December 04, 2007

Detecting Whether the Application is Already Running

Recently a colegue of mine needed to know how he can determine whether his application is already running in the machine at application start.

Using this post I am going to share the solution with you all, showing how you can determine whether your application is already running in the computer. By detecting this either you can stop starting of the second instance of the application and activate the already running application for the user or you can attempt to close the earlier application and start the new one. If you does not check this then multiple applications might start and the user might complain about the application performance. Also this may cause problems occurring from locked resources.

* Visual Basic (VB)
Using VB you can easily check this by using the App object.
------------------------------------------------------------
If App.PrevInstance = True Then
MsgBox("The program '" & App.EXEName & "'is already running. Please use the running application.")
End
End If
------------------------------------------------------------

* Visual Basic .NET (VB.NET)
Using VB.NET you can do this by using Diagnostics.Process class.
------------------------------------------------------------
If Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1 Then
Application.Exit()
End If
------------------------------------------------------------

Tuesday, September 25, 2007

Breakpoints are Not Working in Visual Studio - .NET Compact Framework (.NET CF)

Recently I had the issue while debugging a smart device application. All my breakpoints stop functioning. But if I ran the application in the device emulator the breakpoints are working fine.
So it was occurring only when I debug in an actual device (In my case Pocket PC).

After some trying I found that the problem is in the .NET CF which was installed in the Pocket PC.
To fix the thing,
1. Stop all the applications running in the Pocket PC (Do a soft restart or use the Runnning Programs tab in the System -> Memory).
2. Un install the .NET CF from the Pocket PC and soft reset the Pocket PC again.
3. Install the .NET CF in to the Pocket PC. (Also note that you can make the Visual Studio install the .NET CF by starting an application from Visual Studio.)
4. Connect the Pocket PC to the computer using Active Sync and try debugging. In most cases now the breakpoints should work.

If this did not fix the issue you will have to cold reset the Pocket PC and also I would instruct you to reinstall the SDKs (Windows Mobile 5/6 Pocket PC SDKs) if you have any installed.

Monday, August 13, 2007

Debugging Web Services

I tried debugging some Web Methods (WM) in a Web Service (WS) using Microsoft Visual Studio 2005 and noted the following things.

When your WM having simple parameters (Integers, Strings) if you run your project internet explorer will open up with text boxes to enter your parameters. After entering there will be a button named Invoke to invoke the WM. That will invoke your WM with the parameters you have provided.

But the thing is if your WM is accepting complex types as parameters (Objects, Datasets, Tables {Even though it is not recomended to supply complex objects like datasets to WMs there may be scenarios that it will save lot of development time of yours.}) then you will not see either textboxes or an Invoke button. As a result you will not be able to debug the WM.

Do not worry because I found the way to debug.

First you have to publish your WS to Internet Information Services (IIS). To make things simple for you Visual Studio will do the publishing for you. Before that make sure that your IIS is running by typing http://localhost/ in your web browser.

Then right click on your WS project in the Solution Explorer and click on Publish.... This will open up the Publish Web form to you. In that enter the target location as shown. Remember to change the IP address used to your IP address or you can put your machine name or localhost instead using IP address.



Click on Publish. This will create a virtual folder inside IIS and your compiled WS will be copied in to the virtual folder. Now your WS is hosted. In some cases you may have to give permission to the WS. If you needs then open IIS Manager by typing 'InetMgr' in the run windows. Browse to your newly created virtual folder, right click on the folder and click on properties.



In WebService properties window check if 'Script Source Access' check box is checked, if not then check that and click Apply and click Ok.

Now we have published the WS, we'll setup debugging.

Right click the WS in the Solution Explorer and click Properties. In the project properties page click on the Web tab. In that as the default, WS will be set to run on a virtual server comming with Visual Studio. We have to change this because we are not been able to debug on virtual server. To do this select the radio button 'Use IIS Web Server' and set the project URL to the same location you entered in the Publish Web screen.



Now close the WS properties screen and press F5 or Debug -> Start Debugging. This will start the Internet explorer and will load your web service. Keep that as it is and put some breakpoints in the WS code.

Then use the web service. I did use the WS from a PDA application. When ever the call is made the web service will break at the breakpoints you have put then you will be able to debug as usual (using the windows as such Immediate, Watch, etc)

Conclusion
In Visual Studio normally it will start the WS in its virtual server. We have to point that to IIS to make it debuggable. That can be done by setting Web properties in the WS properties.

Tuesday, June 19, 2007

Installing Visual Studio 2005 SP1


Did you try installing SP1 for Visual Studio without any errors? If not or if you are still did not start the installation some of the following details will help.

The list of things that Microsoft had fixed in Visual Studio 2005 SP1 is located at http://support.microsoft.com/?kbid=918526.

Most of the time the setup will fail due to the insufficient disk space. So before trying to install the SP1 check whether you have at least 6.3 GBs of free disk space. If you have installed VS in other partition than Windows I recommend to check for free disk space in both partitions.
Another common error which can happen when installing this is,

Error 1718. File FileName was rejected by digital signature policy.

This error is due to the Software Restriction Policies (also known as SAFER) that exist in the operating systems that came after Windows XP. This was introduced to help users avoid running unsafer files. SAFER will be used by Windows Installer to check the file signatures to confirm that the files were not tampered. Note that this error can happen when installing any large Windows installer package or Windows installer patch.

This error occurs when there is no contiguous piece of virtual memory to accommodate the file. Then the Windows installer will fail to validate the file and result in this error.

There are few things you can do to fix this,

1. You can edit the registry to make the PolicyScope value to 1 before you install the package.

2. By changing the SAFER settings to allow administrators to install the package.

3. Installing the hotfix if you are running Windows 2003,

For any of this you can get more information from Microsoft by visiting http://support.microsoft.com/?kbid=925336.

Apart from that Visual Studio SP1 release note can be found at http://support.microsoft.com/?kbid=928957.

Also I suggest that you refer Heath Stewart's articles for more installation tips. Heath is Technical Lead working at Microsoft http://blogs.msdn.com/heaths/archive/tags/VS+2005+SP1/default.aspx.

Even though I had no luck recovering the applications without formatting the system which crashed with the failed installation of Visual Studio SP1, I guess you will have much more luck after reading these articles.

Thursday, February 08, 2007

Visual Studio 2005 not adding reference dlls to the deployment project

Recently I did face a problem when I created the setup for my Pocket PC application. My application had several projects and each project is supposed to add a dll to the setup. The problem was when I build the project it didn't add the reference dlls to the setup but only added the main application.

Later I found the solution for this which was to remove the main project output from the deployment project then go to debug mode and add the main project back again to the deployment project. The when the project is rebuilt all the dlls will be included properly.

Saturday, January 13, 2007

Setting up Networking in the Device Emulator

The method to connect the new Device Emulators that come with Visual Studio 2005 is different from the Emulators that came with Visual Studio 2003. The earlier version of emulators were able to connect to the external world by just clicking the Open and giving the network path to be opened in the File Explorer. But the new one if you try the same way it will give you and error saying there are no modem entries and also there are no network card present.
So if you would like to connect your emulator to the external world, please continue reading.

First thing you need to do is to install the Virtual Machine Network Driver for Microsoft Device Emulator.
To download that visit,
http://www.microsoft.com/downloads/details.aspx?familyid=DC8332D6-565F-4A57-BE8C-1D4718D3AF65&displaylang=en.

Then install it in your machine.

After installing it, new item will come under your network connection properties named "Virtual Machine Network Services". To make the emulator use your current network connection, you have to select the "Virtual Machine Network Services" check box. Afterwards it will use this connection when connecting out side.
To configure the Device Emulator to use the network, start the emulator of your choice, then go to File->Configure... . In the network tab select "Enable NE2000 PCMCIA network adapter and bind to" check box and press Ok. Now the emulator has a connection to use but to properly connect we need to set the network settings in the emulator.

Go to Click on Start->Settings and select Connections in the emulator. Then select "Network Cards".

Select "NE2000 Compatible Ethernet Driver" from Configure Network Adapters screen.


From here onwards you need to setup the settings as required by your network. The easiest way is to open the Network connection properties of your machine and set the emulator according to it.

After doing the settings you have to restart the device emulator to make the changes effective by clicking File->Reset->Soft from the emulator screen.

When the device restarts your emulator will have the ability to access the network.

To test the connectivity open the File Explorer from the Programs. Then click on Menu -> Open Path-> New Path.... Then type a valid path in your network and press Ok. Then you will be prompted for a User name, Password and a Domain. Fill the applicable details and press Ok.

If it doesn't get connected check the emulator connection settings. Check whether you need to setup proxies. To setup proxies click Start->Settings and go to Connections tab and select Connections and click on the "Set up my proxy server". Select "This network connects to internet" check box to make the emulator access internet. If proxies are used then enter the proxy details also.

If you correctly setup, the emulator will connect to the network and internet without problems.