The apostrophe in javascript is its string delimiter. To render the apostrophe on the response without errors it must be escaped using backslash \.
alert('John\'s name') will produce message box with text: John's name.
Using asp.net usually the scripts are built dynamically on server side before rendering the page. Remember that the backslash is also escape character in C# and you have to put two backslashes to build the javascript correctly:
Response.Write("alert('John\\'s name');");
FTP over SSL with IIS is not supported.
This is a common problem when you need more secure connection. Microsoft explains the features of their FTP server here:
http://support.microsoft.com/kb/283679
It is good to know that current FTP Service in IIS doesn't support Secure Sockets Layers (SSL). Of course that means your connection details and credentials to such service can be caught by Network listeners between you and the server. Therefore if you need secured connection you have to consider usage of Webdav over SSL or another FTP server which supports SSL.
A suggestion for free and easy to set up server is FileZilla FTP Server for Windows.
http://support.microsoft.com/kb/283679
It is good to know that current FTP Service in IIS doesn't support Secure Sockets Layers (SSL). Of course that means your connection details and credentials to such service can be caught by Network listeners between you and the server. Therefore if you need secured connection you have to consider usage of Webdav over SSL or another FTP server which supports SSL.
A suggestion for free and easy to set up server is FileZilla FTP Server for Windows.
Edit shortcuts in Places bar in Save dialog / Open dialog in Windows
It's absolutely boring to navigate to your most often used folder in windows save or open dialogs. Th purpose of Places bar is to help you to do this faster. The Places bar locations can be edited via Group Policy editor in Windows XP Pro and Vista. Use the following way:
1. Open gpedit.msc (Start->Run)
2. Navigate to User Configuration -> Administrative Templates -> Windows Components -> Windows Explorer -> Common Open File Dialog
3. Open "Items displayed in Places bar" and write down the locations you want with their paths. Symbolic names are also allowed like Desktop.
1. Open gpedit.msc (Start->Run)
2. Navigate to User Configuration -> Administrative Templates -> Windows Components -> Windows Explorer -> Common Open File Dialog
3. Open "Items displayed in Places bar" and write down the locations you want with their paths. Symbolic names are also allowed like Desktop.
SQL: How to check for existing contraint
Just an example how to get it form the database information schema:
IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA='dbo' AND CONSTRAINT_NAME='IX_Constraint' AND TABLE_NAME='TableName')
BEGIN
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT ..... /* constraints */
END
IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_SCHEMA='dbo' AND CONSTRAINT_NAME='IX_Constraint' AND TABLE_NAME='TableName')
BEGIN
ALTER TABLE [dbo].[TableName] WITH CHECK ADD CONSTRAINT ..... /* constraints */
END
How to set column width in a CheckBoxList in an ASP.NET page
Maybe this is common problem since CheckBoxList control doesn't have set of parameters for obtaining column width and row height. But we always can use CSS for styling this control getting in mind he is rendered as html table or floated div tag.
Here we explicitly define the layout to be rendered as table (which is by default) and also need to define the css class "chkBoxList" in current page or web site theme.
Of course any other css styles can be attached here.
Only ASP.NET :)
<asp:checkboxlist runat="server" id="chkBoxList1" cssclass="chkBoxList" repeatcolumns="4" repeatlayout="Table">
</asp:checkboxlist>
Here we explicitly define the layout to be rendered as table (which is by default) and also need to define the css class "chkBoxList" in current page or web site theme.
<style>
.chkBoxList tr
{
height:24px;
}
.chkBoxList td
{
width:120px; /* or percent value: 25% */
}
</style>
Of course any other css styles can be attached here.
Only ASP.NET :)
SQL Stored Procedures - getting return value
Starting directly with example:
The following calling of the procedure shows how to get output parameter.
Of course this example is pretty simple - only for showing how to use. For such usage the SQL scalar-valued functions are better way.
CREATE PROCEDURE ProcessValue
(
@value int,
@returnValue int OUTPUT
)
AS
BEGIN
/* do calculation and processing and assign the result value to output parameter */
SET @returnValue = value + 5*value
END
The following calling of the procedure shows how to get output parameter.
declare @result int
EXEC ProcessValue 15, @result OUTPUT
Of course this example is pretty simple - only for showing how to use. For such usage the SQL scalar-valued functions are better way.
Way for localizing MessageBox in Windows Forms
Very good article in code project, where you can see how the buttons of MessageBox can use custom text labels. The natural language of .NET platform will be overridden and only your labels will be shown.
http://www.codeproject.com/KB/miscctrl/Localizing_MessageBox.aspx
Actually if you use MessageBoxOptions in the parameters of MessageBox.Show(..) only the original labels are shown. But I don't think this is big problem.
http://www.codeproject.com/KB/miscctrl/Localizing_MessageBox.aspx
Actually if you use MessageBoxOptions in the parameters of MessageBox.Show(..) only the original labels are shown. But I don't think this is big problem.
How to map an extension for server side scripting - html to php
Sometimes we need including some functionality or server includes into static web files - html. But changing the extension can lose current search engine index and rank. That is why leaving the fiels with the same name is the better way. Easy html files can be mapped to be parsed as php file.
IIS 7.0:
1. Open IIS Management Console
2. Open Web-site node
3. Open Handler Mapping
4. Add the extension as request path (*.html)
5. Set the handler application/library: something like C:\Program Files\PHP\php5isapi.dll
6. Name it and click OK
Apache:
Just add the following row in the .htaccess file:
AddType application/x-httpd-php .html
IIS 7.0:
1. Open IIS Management Console
2. Open Web-site node
3. Open Handler Mapping
4. Add the extension as request path (*.html)
5. Set the handler application/library: something like C:\Program Files\PHP\php5isapi.dll
6. Name it and click OK
Apache:
Just add the following row in the .htaccess file:
AddType application/x-httpd-php .html
SQL Server 2005 - Out Of Memory exceptions connected to its RAM usage
After the allocated RAM for SQL Server exceeds the System memory unexpected behavior of the server is present.
Here is a quick guide for configuring Sql server.
http://www.mattec.com/service/appnotes/820-0019.pdf
And remember: Never allocate less then 1 GB of RAM to SQL Server :)
Here is a quick guide for configuring Sql server.
http://www.mattec.com/service/appnotes/820-0019.pdf
And remember: Never allocate less then 1 GB of RAM to SQL Server :)
VB.NET: General Exception Handling in Windows Forms
VB.NET
My.Application.UnhandledException Event is the way for handling all unhandled exceptions in an windows forms application. The application raises this event when it encounters unhandled exception.
For using the event editing ApplicationEvents.vb file is needed. By default ApplicationEvents.vb is hidden. For openning (unhiding) it use Project Properties -> Application tab -> View Appication Events.
Then the handler can be added/edited as in the example below:
C#
Of course most of my posts give examples with VB and C# when they are different. Now I will give up this pleasure to R. Newman with his great post "Top-level Exception Handling in Windows Forms Applications"
My.Application.UnhandledException Event is the way for handling all unhandled exceptions in an windows forms application. The application raises this event when it encounters unhandled exception.
For using the event editing ApplicationEvents.vb file is needed. By default ApplicationEvents.vb is hidden. For openning (unhiding) it use Project Properties -> Application tab -> View Appication Events.
Then the handler can be added/edited as in the example below:
And from now on all unhandled exception in the application will be stored as exception information and stack trace in the application log file or in the Windows Event log and the user will receive friendly message.
Private Sub MyApplication_UnhandledException( _
ByVal sender As Object, _
ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs _
) Handles Me.UnhandledException
Try
//write log, which is nessted in Application Data folder
My.Application.Log.WriteException( _
e.Exception, _
TraceEventType.Critical, _
"Unhandled Exception!")
//check up if the Event folder exists.
//if not - create new one
If Not EventLog.SourceExists("My software") Then
EventLog.CreateEventSource("My software", "My Software")
End If
//write event log, can be seen by Event Viewer
EventLog.WriteEntry("My software", _
e.Exception.ToString(), _
EventLogEntryType.Error)
Catch ex As Exception
End Try
// code for notifying the user with user friendly message
...................
//set the default application action (closing) not to be performed.
e.ExitApplication = False
End Sub
C#
Of course most of my posts give examples with VB and C# when they are different. Now I will give up this pleasure to R. Newman with his great post "Top-level Exception Handling in Windows Forms Applications"
How to check the type of an object or control using VB.NET or C#
The VB.NET check up is:
And the C# code:
If (TypeOf sender Is TextBox)Then
Dim txt As TextBox= DirectCast(sender, TextBox)
End If
And the C# code:
if (sender Is TextBox){
TextBox txt=(TextBox)sender;
}
Error reporting in PHP run on IIS
The PHP error reporting is controlled either by the php.ini file as a global setting or programatically, or using .htaccess.
The error reporting in php.ini is defined in "Error handling and logging" section.
In .htaccess the flags must be changed in the following way:
Php error_reproting help -> http://php.net/error_reporting
The error reporting in php.ini is defined in "Error handling and logging" section.
- error_reporting = E_ALL & ~E_NOTICE - shows all errors except E_NOTICE errors. E_NOTICE are possible errors which can occur even during normal program workflow - something like Microsoft's warnings.
- display_errors = On
- display_startup_errors = On
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting(E_ALL & ~E_NOTICE);
In .htaccess the flags must be changed in the following way:
php_flag display_errors 1
php_flag display_startup_errors 1
Php error_reproting help -> http://php.net/error_reporting
URL Encoding - reserved and unsafe characters
RFC 1738: Uniform Resource Locators (URL) specification is described in the following page. Also simple convertor is included.
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
Server.URLEncode(url)applies these rules to the url. During getting an url parameter from the query string the value will be automatically decoded.
Javascript trace log
Simple and useful tool can be found here:
http://v2.easy-designs.net/code/jsTrace/
Using it you can get rid of the alert messages while debug applications.
http://v2.easy-designs.net/code/jsTrace/
Using it you can get rid of the alert messages while debug applications.
Subscribe to:
Posts (Atom)