ExtensionMethod.NET Home of 819 C#, Visual Basic, F# and Javascript extension methods

GetQueryStringValue

Gets a query string value from a System.Web.UI.UserControl HTTP Request object.

Source

using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web;

namespace WebExt
{
    public static class WebExt
    {
        public static T GetQueryStringValue<T>(this UserControl control, string name)
        {
            return (T)Convert.ChangeType(control.Request.QueryString[name], typeof(T));
        }
    }
}

Example

var queryStringVal = this.GetQueryStringValue<int>("param");

Author: James Levingston

Submitted on: 26 jan 2011

Language: C#

Type: System.Web.UI

Views: 3496