April 9, 2013

Display Text After 5 seconds On Page Refresh

This post shows the demonstration on how to show text after some seconds in Asp.net application. Here we use JavaScript to fulfil this need.


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    
    <script type="text/javascript">

        $(document).ready(function(){
          setTimeout(function(){
            $('#delayText').show();
            }
          , 5000);
        });
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span id="delayText" style="display:none;">Hello Testing</span>
    </div>
    </form>
</body>
</html>

April 1, 2013

Avoid Potential Dangerous Request Error Message

You will get this error message from server when server see HTML mark up in HTML fields. To avoid error message of "Potential Dangerous Request", you need to do following precautions.

1.  Add ValidateRequest & EnableEventValidation attribute as "false" in @Page tag as:


<%@ Page Title="Untitle Page" Language="C#" MasterPageFile="~/Master.Master" 
    AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" 
    EnableEventValidation="false" ValidateRequest="false" %>


2. If still receive an error, then add requestValidationMode attribute in httpRuntime configuration section in web.config file as:


<httpRuntime requestValidationMode="2.0"/>

3.   But If there is no httpRuntime section in web.config file then add ValidateRequest attribute in web.config file within <system.web> tag as:


<pages validateRequest="false" />


If you have any issue remaining then let me know. Stay tune.