Showing posts with label Web Development. Show all posts
Showing posts with label Web Development. Show all posts

Thursday, 27 November 2014

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list


This command just surprisingly solved it:

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i


This repeats IIS registration\installation although I had no problem while installing it as Windows Feature.

Thursday, 31 July 2014

A lot more to know about RTL [Reference to external article]

Ahmed Alfy has developed a very neat article talking about localizing the user interface for web applications in general.

RTL (Right to Left) refers to the direction change for some languages which is required as one of the basic steps for localizing these applications.

Let's Talk About RTL

Enjoy!

Sunday, 5 January 2014

Can not start debugging for ASP.NET 1.1 Visual Studio projects

Issue:
Whenever I start debugging on my project, it starts and ends immediately after launching the web browser; however, all the breakpoints are ignored!

Resolution:
Those two steps solved my issue:
1) Strange enough, I unchecked the option for turning on pop up blocker in IE.
2) Makes more sense, I fixed ASP.NET 1.1: through:

C:\Windows\Microsoft.net\Framework\v1.1.4322\aspnet_regiis -ir

Wednesday, 6 November 2013

Google Chrome --allow-file-access-from-files flag, a solution or a workaround

--allow-file-access-from-files: This is an application flag so that some functions can run successfuly if initiated from the local filesystem rather than a web server.

The reason Google announces for this behaviour: Security!
http://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html

After hours of searching the topic, I can tell my personal opinion  as this is a workaround for a problem caused by a poor security threat implemented workaround!


My root issue was: Being unable to transform an XML using an XSL within the same filesystem container (Folder in NTFS). I did receive blank page in chrome; however that worked fine in IE.

test.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<testing>
<T1>
<title>Hello...</title>
<Item2>World!</Item2>
</T1>

</testing>

test.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <h2>My Tests</h2>
    <table border="1">
      <tr bgcolor="red">
        <th>Item1</th>
        <th>Item2</th>
      </tr>
      <tr>
        <td><xsl:value-of select="testing/T1/title"/></td>
        <td><xsl:value-of select="testing/T1/Item2"/></td>
      </tr>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>



More details about how to use this flag: http://www.chrome-allow-file-access-from-file.com/

Thursday, 14 February 2013

ASP.NET page life cycle

Request --> Startup --> Initialization --> Loading --> Postback Handling --> Rendering --> Unloading!

The most comprehensive reference I can really recommend is within the MSDN:
http://msdn.microsoft.com/en-us/library/7949d756-1a79-464e-891f-904b1cfc7991.aspx

Wednesday, 23 January 2013

Simplest way to add a password strength indicator




Using ASP.NET AJAX Control toolkit:

<asp:TextBox ID="TextBox_Password" runat="server" Width="220px"></asp:TextBox>
<ajaxToolkit:PasswordStrength ID="PasswordStrength_Password" runat="server
   TargetControlID="TextBox_Password"
   DisplayPosition="RightSide"
 
   StrengthIndicatorType="BarIndicator"
 
   PreferredPasswordLength="8"
   MinimumNumericCharacters="1"
   MinimumSymbolCharacters="1"
   RequiresUpperAndLowerCaseCharacters="true"
 
   TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"
   BarBorderCssClass="barIndicatorBorder"
   StrengthStyles="barIndicator_VeryPoor; barIndicator_Weak; barIndicator_Average; barIndicator_Strong; barIndicator_Excellent"

   CalculationWeightings="50;15;15;20" />


Styles in css:

/*Password strength bar*/
.barIndicatorBorder {
    border: solid 1px #c0c0c0;
    width: 200px;
}

.barIndicator_VeryPoor {
    background-color: red;
}

.barIndicator_Weak {
    background-color: orange;
}

.barIndicator_Average {
    background-color: lightblue;
}

.barIndicator_Strong {
    background-color: greenyellow;
}

.barIndicator_Excellent {
    background-color: green;
}


Monday, 12 November 2012

ASP.NET: System.Web.HttpException (0x80004005)

Error:
System.Web.HttpException (0x80004005): The URL-encoded form data is not valid. ---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)


Resolution:
Web.config:

<configuration>
<appSettings>


            <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
            <add key="aspnet:MaxJsonDeserializerMembers" value="5000" />



If ASP.NET 1.1:
Add the following key to the registry:


HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\1.1.4322.0\MaxHttpCollectionKeys

Value: 5000

Reference:
http://support.microsoft.com/kb/2661403

Sunday, 11 November 2012

Date validation using JavaScript function


sub isvaliddate {
  my $input = shift;
  if ($input =~ m!^((?:19|20)\d\d)[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$!) {
    # At this point, $1 holds the year, $2 the month and $3 the day of the date entered
    if ($3 == 31 and ($2 == 4 or $2 == 6 or $2 == 9 or $2 == 11)) {
      return 0; # 31st of a month with 30 days
    } elsif ($3 >= 30 and $2 == 2) {
      return 0; # February 30th or 31st
    } elsif ($2 == 2 and $3 == 29 and not ($1 % 4 == 0 and ($1 % 100 <> 0 or $1 % 400 == 0))) {
      return 0; # February 29th outside a leap year
    } else {
      return 1; # Valid date
    }
  } else {
    return 0; # Not a date
  }
}



This is an excerpt from another community work.

Sunday, 23 September 2012

Optional\Default ASP.NET parameters

Protected Sub DisplayControls( Optional param As Boolean = False)
.
.
.
End Sub



Call DisplayControls(True)


or 

Call DisplayControls(True)

Tuesday, 4 September 2012

Compiler Error Message: BC30456: 'Theme' is not a member of ...


Placing an image (element) in front of another on a webpage

If you would like to position an object\element in front of another one, you can use the very handy style property z-index to a higher number

style="z-index:2; position:absolute;"


N.B.: z-index works only on positioned elements

Sunday, 2 September 2012

Regular Expression for date validation

For the format dd/mm/yyyy:

ValidationExpression="^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$"

Thursday, 30 August 2012

Formatting a FormView data bound string


Instead of:
<asp:Label ID="Label_Age" runat="server" 
Text='<%# Eval("CalculatedAgeMonths") %>' />

Use:
<asp:Label ID="Label_Age" runat="server" 
Text='<%#  ConvertToYearsMonths(Eval("CalculatedAgeMonths")) %>' />


And in your code behind:
Function ConvertToYearsMonths(CurrentMonths As Integer) As String

     Return "in Years!!"

End Function

Microsoft IIS Versions


MS IIS: Microsoft Internet Information Server

XP       = IIS 5.1
Server 2003 = IIS 6
Server 2008 = IIS 7
Windows 7   = IIS 7.5

Thursday, 9 August 2012

Thursday, 2 August 2012

Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider.


Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider. Otherwise, set the EnableSanitization property to false.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Sanitizer provider is not configured in the web.config file. If you are using the HtmlEditorExtender with a public website then please configure a Sanitizer provider. Otherwise, set the EnableSanitization property to false.




Place the below section just below the openieng of "<configuration>" tag within the file "web.config"


<configSections>
        <sectionGroup name="system.web">
            <section name="sanitizer" requirePermission="false" type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit"/>
        </sectionGroup>
    </configSections>
    <system.web>
        <sanitizer defaultProvider="AntiXssSanitizerProvider">
            <providers>
                <add name="AntiXssSanitizerProvider" type="AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider"></add>
            </providers>
        </sanitizer>
    </system.web>


Anti-XSS can be easily obtained using NuGet. (Similar to previous post for installing AjaxControl Toolkit)

Visual Studio 2010 --> Tools --> Library Package Manager --> Package Manager Console -->
PM> Install-Package AntiXSS

You will get the below error if Anti-XSS is not installed:

Could not load type 'AjaxControlToolkit.Sanitizer.AntiXssSanitizerProvider'


Tuesday, 31 July 2012

AJAX TabContainer within FormView fails to insert\update data


Unfortunately that is true, you have to transfer the data manually as below:

Protected Sub SqlDataSource_Updating(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource_Patient.Updating

The following is how to reference a TextBox from a TabContainer inside a FormView:
Dim TabContainer_CaseInfo As TabContainer =                        CType(FormView_Main.FindControl("TabContainer_CaseInfo"), TabContainer)

Dim TabPanel_Basic As TabPanel =  
     CType(TabContainer_CaseInfo.FindControl("TabPanel_Basic"), TabPanel)

Dim DOBTextBox As TextBox = CType(TabPanel_Basic.FindControl("DOBTextBox"), TextBox)


More references:
http://stackoverflow.com/questions/969784/ajax-tabcontainer-inside-formview-not-inserting-values

Monday, 30 July 2012