Saturday, February 28, 2009

Javascript Parent Child window / window.open method / Open PopUp window

Do you want to open PopUp window from your current window. It can open by using javascript's window.open method. The new opened window is called the Child window and from which window you have open it is called Parent window.

The syntax of window.open is as follows:

open (URL, windowName[, windowFeatures])

Where URL is the url of the page which you want to open.
windowname is a name given to the new window
windowFeatures is the string which can include status bar, address bar etc.. window features will be included in the new popup window.

For example:
window.open ("http://vijaymodi.wordpress.com","Vijay Modi's Blog");

will opens a new browser window with standard features.

To open a window with statusbar and toolbar you have to write the following code:
window.open ("http://vijaymodi.wordpress.com","Vijay Modi's Blog","status=1,toolbar=1");

The following table shows the features and the string tokens you can use in the features depends on your requirements:
status The status bar at the bottom of the window.
toolbar The standard browser toolbar, with buttons such as Back and Forward.
location The Location entry field where you enter the URL.
menubar The menu bar of the window
directories The standard browser directory buttons, such as What's New and What's Cool
resizable Allow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
height Specifies the height of the window in pixels. (example: height='350')
width Specifies the width of the window in pixels.

Regards,
Vijay Modi

Sunday, February 22, 2009

Javascript Parent Child window / window.open method / Open PopUp window

Do you want to open PopUp window from your current window. It can open by using javascript's window.open method. The new opened window is called the Child window and from which window you have open it is called Parent window.

The syntax of window.open is as follows:

open (URL, windowName[, windowFeatures])

Where URL is the url of the page which you want to open.
windowname is a name given to the new window
windowFeatures is the string which can include status bar, address bar etc.. window features will be included in the new popup window.

For example:
window.open ("http://vijaymodi.wordpress.com","Vijay Modi's Blog");

will opens a new browser window with standard features.

To open a window with statusbar and toolbar you have to write the following code:
window.open ("http://vijaymodi.wordpress.com","Vijay Modi's Blog","status=1,toolbar=1");

The following table shows the features and the string tokens you can use in the features depends on your requirements:
status The status bar at the bottom of the window.
toolbar The standard browser toolbar, with buttons such as Back and Forward.
location The Location entry field where you enter the URL.
menubar The menu bar of the window
directories The standard browser directory buttons, such as What's New and What's Cool
resizable Allow/Disallow the user to resize the window.
scrollbars Enable the scrollbars if the document is bigger than the window
height Specifies the height of the window in pixels. (example: height='350')
width Specifies the width of the window in pixels.

Regards,
Vijay Modi

Wednesday, February 18, 2009

ASP.Net Send mail

I have write a function to send mail in asp.net. Sending mail is an important feature of each and every project. And so I write this article and providing one function to send mail.

Public Function SendMail(ByVal Sender As String, ByVal Receiver As String, ByVal Subject As String, _
ByVal CC As String, ByVal BCC As String, ByVal Message As String)

Dim NewMailToUser As New MailMessage
NewMailToUser.To = Receiver
NewMailToUser.From = Sender

If Not (CC = String.Empty) OrElse Not IsNothing(CC) Then
NewMailToUser.Cc = CC
End If

If Not (BCC = String.Empty) OrElse Not IsNothing(BCC) Then
NewMailToUser.Bcc = BCC

End If

NewMailToUser.Subject = Subject
NewMailToUser.BodyFormat = MailFormat.Html
NewMailToUser.Body = Message
SmtpMail.SmtpServer = String.Empty 'SMTP server name or address. You have to change depends on your SMTP server
SmtpMail.Send(NewMailToUser)

End Function

You can use this function to send mail and you can call it as following:

SendMail(strSender, strTo, strSubject, Nothing, Nothing, strMessage)

Enjoying Programming,
Regards,
Vijay Modi

CGI Error-The specified CGI application misbehaved by not returning a complete set of HTTP headers

The "CGI Header" error typically this happens more on a faster machine (it has to do with timing of IIS/PHP and database connections). Logging out of the PureCMS system might result in IIS responding with a CGI Error. Refreshing the client browser (press the F5 key) typically results in the login page correctly appearing. If this error happens regularly, try configuring your web server to be optimized for Programs (not Background Services). These options can be found in the System control panel under Performance Options.

There is another option if optimizing your Web server for Programs does not solve the problem. There is a free utility called "FastCGI" that is a generic "plug in" for IIS that helps to execute CGI applications (PHP, Perl, etc.) faster by pooling those processes rather than making IIS launch them for every request. This has been shown to work well with PureCMS to avoid the "CGI Header Error" issues mentioned above.

Setting Up FastCGI on IIS for PureCMS

Download http://www.caraveo.com/fastcgi/fastcgi-0.6.zip and unpack isapi_fcgi.dll.
Place the "isapi_fcgi.dll" file into the "App\PHP" subfolder of your PureCMS installation directory, e.g. "D:\PureCMS\App\PHP" (the same directory as php.e-x-e)
Copy and paste the following text (between the "----" lines) into a text editor (such as Notepad). Modify the file path for PHP appropriately (point it to your installation folder for PureCMS), and save the file with a ".reg" extension. Then double-click that file and click "Yes" to merge this information into your registry. Make sure that the file names are in 8.3 format. For example, instead of "c:\program files\globalscape\purecms" use "c:\progra~1\global~1\purecms".
------------------- fastcgi.reg -------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI]
"StartServers"=dword:00000005
"IncrementServers"=dword:00000002
"MaxServers"=dword:00000019
"Timeout"=dword:00000258

[HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI\.php]
"AppPath"="D:\\PureCMS\\app\\php\\php.exe"
"BindPath"="php-fcgi"
---------------------------------------------------------

Change script mappings for .PHP to point to D:\PureCMS\app\php\isapi_fcgi.dll instead of PHP.exe. This is done in the IIS manager: right-click on the PureCMS site and choose "Properties." Change to the "Home Directory" tab and click the "Configuration" button in the bottom right. Go to the "App Mappings" tab. Find the ".php" extension in the "Application Mappings" list, click it and choose "Edit." For the Executable entry, "Browse" and find the isapi_fcgi.dll location and choose that.
If you are configuring IIS on a Win2K3 machine, you must also take the extra step of adding it as an allowed ISAPI extension. (see IIS help file for more details, or ask us to help!)
If you are not running on Win2K3, you should toggle Application protection from "High" to Medium" to "High" due to some weird IIS issue. To do so, right-click on your PureCMS site in IIS manager and choose Properties. In the "Home Directory" tab, change the "Application Protection" list to "Medium" and press APPLY. Then change it back to "High" and press Apply again. If you are curious about why this is necessary, read here: http://www.ensim.com/support/wwp/documents/wwp_pro_3.2_docs/wwp32_applHelp/WebHelp/Sites-related.htm
Copy PHP.INI from d:\PureCMS\Main\ into d:\PureCMS\App\php\php.ini (this is a very important step!!!)
8) For FastCGI to work properly, you will need to use PHP 4.3.4; PureCMS ships with PHP 4.3.3.
Download PHP 4.3.4 here, and unzip the following files into your PureCMS PHP folder (e.g. c:\program files\globalscape\purecms\app\php\) -- overwrite whatever files are already there: php.exe, php_ts.dll, and mssql.dll
Restarted the web server. To do so, open a command prompt window and type "iisreset".
Access PureCMS from a browser. Installing FastCGI should eliminate the "This application has misbehaved" errors.
Reference: http://help.globalscape.com/help/purecms3/Error_Message__CGI_Error-The_specified_CGI_application_misbehaved_by_not_returning_a_complete_set_of_HTTP_headers.htm

Regards,
Vijay Modi

Saturday, February 14, 2009

Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of

Hello Friends,

Its not actually an error. Its a message telling you that you cannot view the error.

You have to do the following to resolve this problem.

First setting in the web.config will display you the actual errror. Also check if you have the correct .NET version installed on the server and your \test folder is configured to the right .net version.

If still getting the same error the do the following:

In the IIS, right click on your website and in the properties dialog, click on the ASP.NET tab and set the correct version. For example see the following snap.





If you find this article resolved your problem, please add your comments. You can add your suggesions too.
Regards,
Vijay Modi

Monday, February 9, 2009

COM+ was unable to talk to the Microsoft Distributed Transaction Coordinator

To resolve this problem go through the following steps:

Go to Start > Run
Write the cmd and click on ok button. Command prompt will open.
Write the following commands
> msdtc -uninstall
> msdtc -install

This will resolve your problem.

You can see another solution on the following link too:
http://support.microsoft.com/kb/867520

Regards,
Vijay Modi

Thursday, February 5, 2009

ASP.Net + Removing controls from groupbox using ForEach loop

Hi Friends,

Yesterday I was resolving a problem. I was getting that I am removing same control from a group box. I am giving you an example. I add 10 same controls dynamically in the group box. Then on one click on Remove button, I need to remove all these controls from group box. The code was written by me was as follows:

foreach (Control ctl in grp1.Controls)
{
if (ctl.GetType().ToString().EndsWith(".ctl1"))
{
grp1.Controls.Remove(ctl);
}
}

When I debug this code, understand the problem that all the controls are not removing from this group box. Then I change the logic with the following one.

int intNoOfControls = grp1.Controls.Count;
for (int i = intNoOfControls - 1; i >= 0; i--)
{
if (grp1.Controls[i].GetType().ToString().EndsWith(".ctl1"))
{
grp1.Controls.Remove(grp1.Controls[i]);
}
}

This code working perfect and resolve the problem. But do you know what was the problem there in for each loop? Its really very interesting. When I am going to remove control from for each loop its removing and compare with the (group box controls -1) controls (i.e. its reinitialize the controls). So its not removing all the controls from the group box.

Note: If you want to add your comments for this article please add it below. Your suggesion are really great advice for me.

Thanks Buddy,
Vijay Modi

Monday, February 2, 2009

DataGridView + Focus to a Row Cell

I have to check the validation of DataGridView and have to check the value should not repeate more then one time. I Solve this problem just by adding the following two lines of code and its working very fine. Do you facing the same problem, Please go through and it will definetely resolve your problem.

If you know the cell, like having a reference to it from the variable desiredCell you can simply do the following:

dataGridView1.CurrentCell = desiredCell;
dataGridView1.BeginEdit(true);

Solve na?? Now add your comments buddy. :)
Regards,
Vijay Modi