Breaking News

Editors Picks

Monday, January 9, 2012

How to access Query string in javascript?


<script type="text/javascript">
    function getParameterByName()
    {
      var name="QueryStringVariableName";
      var value='';
      name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
      var regexS = "[\\?&]" + name + "=([^&#]*)";
      var regex = new RegExp(regexS);
      var results = regex.exec(window.location.href);
      if(results == null)
        value= "";
      else
        value= decodeURIComponent(results[1].replace(/\+/g, " "));
    }

    script>
Read more ...

How to Generate Dynamic Serial Number for GridView Control with Paging?


It is very simple to add serial or sequential number column in a GridView control. Just create TemplateField column in the GridView and add Container.DataItemIndex+1 as inline code. That's it.

Below we have given the sample block of code for your reference.

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" >
  <Columns>
<asp:TemplateField HeaderText="SNO.">
<ItemTemplate>
<%#Container.DataItemIndex+1 %>
ItemTemplate>
asp:TemplateField>
  Columns>
asp:GridView>
Read more ...

System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client.


Server Error in 'ASP.Net' Application.

A potentially dangerous Request.Form value was detected from the client (TextBox1"=Hi").
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (TextBox1="Hi").

ASP.Net By default validates all input controls for potentially unsafe contents that can lead to Cross Site Scripting and SQL Injections. Thus it disallows such content by throwing the above Exception. By default it is recommended to allow this check to happen on each postback.
  Solution
On many occasions you need to submit HTML Content to your page through Rich TextBoxes or Rich Text Editors. In that case you can avoid this exception by setting the ValidateRequest tag in the @Page Directive to false.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestWebPage.aspx.cs"  ValidateRequest="false"  Inherits="TestWebPage" %> 

This will disable the validation of requests for the page you have set the ValidateRequest flag to false. If you want to disable this check throughout your Web Application you’ll need to set it  false in your web.config <system.web> section
<pages ValidateRequest="false " />


Read more ...

Contact Us

Name

Email *

Message *