.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

get reference to RouteCollection

Posted By:      Posted Date: October 04, 2010    Points: 0   Category :ASP.Net

in an action, how do I get a reference to the RouteCollection object?

I am using the QueryString to mantain some state variables and notice when I RedirectToAction the querystring in the redirected to action is null.  So I would like to use RouteCollection.GetUrl and HttpContext.Response.Redirect to create a customized version of RedirectToAction.



View Complete Post

More Related Resource Links

A better way to reference your wizard steps using named steps

Note: this article uses the plain vanilla but the concepts apply equally well to its popular counterpart .

By far the most common way that I see wizard steps reference in code snippets is by their index.

reference from menubuttons to text parts in article on the same page


Hi, I'm searching now for hours but couldn't find it.Cry

In my menu i have several buttons which (by a <a href..) should go the a part of an article that is in the same form.

Menu button : What is a database should go to the page default.aspx and in there is an article published.
A part of this article is having a piece of text about "what is a database"

Menu button: how to make a query should go to this same article in the same page but then to the part that is have the piece about the query. The next could be an example of what i'm doing:

    <li><a href="default.aspx ?????>what is a database</a></li>
    <li><a href="default.aspx ?????>what is a query</a></li>

Where my question marks are, there should be a connection to that particular piece of text.
In each article part there is an ID="text1" and the second part id="text2"

How shoudl i do that, Should i use a question mark.
Please give me some guidance how to structure the <li> statement or a pointer where I can read about it.


Reference HttpApplication from a separate HttpApplication


I want to create a website that can monitor the status of other websites running on the same server. Is this possible? How do I get a reference to a site's HttpApplication context from a separate HttpApplication?

Registering controls of current assembly object reference NOT set error


Hi There,

I have created a simple ASP.net Web Application (2.0) and have added a web user control.

Now in my page I have added this control but I have registered like this,

<%@ Register Assembly="WebApplication1" Namespace="WebApplication1" TagPrefix="Custom" %>

Which means I want to access all the controls in my current Web Application project

Then I have added my user control like this,

<Custom:MyUserControl ID="MyUserControl1" runat="server" PublicProperty="Hello" />

Every thing is fine but when I execute the project, NO control on my user control gets "instantiated" and thus I receive error "Object Reference Not Set"

Note that My Control has,

1) Public property PublicProperty as String

2) 1 Label control

In Load Event Handler I am setting Text property of Label Control to PublicProperty. Here object reference NOT set error occurs (which means Label control is NOT initialized).

I don't want to register my control using Src, TagPrefix etc. Any ideas?


Page.FindControl Causing Null Reference Exception


Hi guys,

I developed a page in VWD 2008 and it works perfectly locally, but when I deployed it on the server every Page.FindControl() call is causing the NullReference Exception "Object reference not set to an instance of an object. " Can anyone help me out? Code is below


Mike Marshall

            For i As Integer = 1 To 10
                If (CType(Page.FindControl("last_" & i), TextBox).Text.Length > 0) Or (CType(Page.FindControl("first_" & i), TextBox).Text.Length > 0) Or (CType(Page.FindControl("dob_" & i), TextBox).Text.Length > 0) Then
                    Dim person_entry(7) As String
                    person_entry(0) = info_list.Count - 1
                    person_entry(1) = CType(Page.FindControl("last_" & i), TextBox).Text
                    person_entry(2) = CType(Page.FindControl("first_" & i), TextBox).Text
                    person_entry(3) = CType(Page.FindControl("dob_" & i), TextBox).Text
                    person_entry(4) = CType(Page.FindControl("appear_" & i), TextBox).Text
                    person_entry(5) = CType(Page.FindControl("mental_" & i), TextBox).Text
                    person_entry(6) = CType(Page.FindControl("behave_" & i), TextB

LINQ Sorting After Goup w/ Table Reference


Having a little trouble here.  I am taking a table (Articles) and grouping all the results by the key that references another table (ArticleSectionCategories).  I then want to sort these results by the OrderBy field of the referenced table (ArticleSectionCategory.OrderBy).  This is what I am using right now but it is not working.  Any thoughts?


                var GroupedArticles = from A in DC.Articles
                                     where A.PackagesId == packageId
                                     group A by A.ArticleSectionCategoriesId into G
                                     select G.OrderBy(C => C.ArticleSectionCategory.OrderBy);


Custom tool error: Failed to generate code for the service reference 'CompanyService'. Please che


A little background because I feel I have an out of the ordinary architecture in place and don't know if this is contributing to the problem. 

We have an existing ASP.net application that is undergoing expansion.  The new functionality is all written in Silverlight 4.  As part of that expansion I gutted all the old Linq to SQL and put Entity Framework 4 into place.  To do this I created a standard .net Class Library and added my edmx files there.  Naturally, the business entities created by this cannot be used in Silverlight.  So I created a Silverlight Class Library and added all the business entities to that Silverlight Class Library as linked files.  I changed the name space to be the same.

So I have the following assembly / namespaces

Company.Project.Dal.csproj / Company.Project.Entities (.net 4 class library)

Company.Project.Entities.csproj / Company.Project.Entities (SL4 class library)

With this architecture I was able to share my business entities with my SL enabled web services, my asp.net projects, my silverlight projects.  Really it's a beautiful thing.

Once this was done I added "message" classes to Company.Project.Dal and again shared them with the other entites using linked files.  These messages are things like MyObjectRequest; they are class

FileUpload error: Object reference error


I have a FormView with a FileUpload to upload an image in a database.

I keep getting an object reference error.(view code)

I am using this same script to upload the image to the database, but when I try to update the file upload I get the error.    

string strFilePath=Server.MapPath("\\images\\"+fupdImage.FileName);

        Byte[] image=null;
        HttpPostedFile imgVid=FileUpload.PostedFile;

        image=new Byte[imgVid.ContentLength];//Object reference not set to an instance of an object.

        if(FileUpload.HasFile) {
        string imageFile=FileUpload.PostedFile.FileName;
        int index=imageFile.LastIndexOf(".");
        string fileFormat=imageFile.Substring(index+1);


How to reference a listbox from a procedure


I have a listbox that gets loaded from a couple of different places on my web form.

I would like to put the code to load the listbox in one place, rather than have two copies of it.

The problem is, I can't figure out how to reference the listbox control successfully from within a procedure.

Would anyone know how to do this?

My code looks like this:

private static bool LoadSubscriptionListBox(System.Web.UI.Page Page)
        bool bReturn = false;

        // Clear the listbox

        // Load the listbox



Cannot access Label inside Repeater - "Object reference not set..."


I have a button on a page with a Repeater and an ObjectDataSource. To give credit where credit is due, the Repeater's paging functionality is courtesy of ScottGu. (However, I'm using ASP.NET 4.0 and SQL Server 2008, as opposed to ASP.NET 2.0 and SQL Server 2005.)

Anyway, in the button's click event, I need to access the Text property of a Label that's inside the Repeater because it's used as an input parameter in a stored procedure. I'm getting a NullReferenceException when trying to access the Label's Text property. I have researched this error and have tried a few different solutions (involving FindControl and the Repeater's ItemDataBound event), but I haven't been able to get it to work. Any suggestions, in VB or C#, would be greatly appreciated. The code is below.


<asp:Repeater ID="rptText" runat="server" DataSourceID="tbsDataSource">
<table width="100%" cellspacing="1">
<%-- some rows removed for brevity --%>

The DELETE statement conflicted with the REFERENCE constraint


I have created ASP.Net Dynamic data web site using scaffolding in Visual Studio 2010. When I click on delete in data grid for customer table I got below error message.

The DELETE statement conflicted with the REFERENCE constraint "FK_Order_Details_Products". The conflict occured in database "../NORTHWIND.MDF", table "dbo.order details", column 'ProductId'

The statement has been terminated


VS2010 Silverlight 4 - Getting "Object reference not set to an instance of an object" when loading a

In Visual Studio 2010 I'm trying to use the Blacklight Controls (http://blacklight.codeplex.com/releases/view/37652) in my own project (and actually included the Blacklight.Controls project in my solution so that I could debug what was going on) and... after making all the XAML changes needed to incorporate the Blacklight navigation menu with my stuff in the innermost grid... everything compiled ok when doing a Build.  When I run it there's a reference to a resource dictionary in the XAML that fails with the object reference error above.  The XAML is as follows:       <UserControl.Resources>       <controls:ResourceDictionaryManager x:Key="ResourceDictionaryManager">       <controls:ResourceDictionaryManager.ResourceDictionaries>       <controls:ResourceDictionaryCollection>       <controls:ResourceDictionary Path="/Blacklight.Showcase;component/ResourceDictionaries/DavesGlossyControls.xaml">       <controls:ResourceDictionary.ResourceKeys>       <controls:ResourceKeyCollection>       <controls:ResourceKey ResourceName="GlossyBlackScrollViewer" />       </controls:ResourceKeyCollection>     &

The type 'DataGrid' was not found. Verify that you are not missing an assembly reference and that

Hi; I'm new to WPF and I was going through the ExpenseIt tutorial on MSDN's website. The tutorial was working fine until I added DataGrid. I got the error message: "The type 'DataGrid' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built."     I could not find a clear answer online of which assembly references to fix and how to fix them. Any help would be appreciated. Thanks!     Note: I'm running the following: Windows Vista 32-bit operating system Microsoft Visual Studio 2008 Version 9.0.30729.1 SP Microsoft .NET Framework Version 3.5 SP1

Getting error when a reference is added

Hi,      I am new to .Net, i am getting error when i add a reference to my project, i am attaching the error screen shot here, Do i need to addd any reference path anywhere else, i am using VS 2008. Thanks RaviWorking as a software engineer

.Net Regex Resources Reference

For those starting out with Regex'es or even those who are old hands here are some resources to help. .NET Framework Developer's Guide .NET Framework Regular Expressions Regular Expression Language Elements Character Classes such as. \d \s [ ] defined. Quantifiers such as+ * ? { } Options such asMultiline Compiled SingleLine Expression Classes such as Regex Match MatchCollection GroupCollection Regular Expression Examples Tutorials 30 Minute Regex Tutorial on CodeProject. .Net Coders Regex Overview breaks down groups and matches in one of the best overviews of the topics. Introduction to Regular Expressions on CodeProject. Understanding Basic Regular Expression Syntax (Section 3.10.) in the CodeProject's book chapter previewMicrosoft Visual C# .NET 2003 Developer's Cookbook . Its a preview of Chapter 3: Strings and Regular Expressions. Eric Gunnerson's Regex 101 . A listing of differing match topics. Great for a beginner to look at after acquiring the basics of Regex, many examples. How to: Search Strings Using Regular Expressions (C# Programming Guide) in MSDN Library. Topics General Regular Expressions and the If Conditional on OmegaCoder's blog. Want faster regular expressions? Maybe you should think about that IgnoreCase option... (Compilation) For an overview of the three different modes,interpreted, on-the-fly comp

Microsoft.mshtml / mshtml.dll versioning and reference issues

Hi, Couldn't find a more relevant section to put this in, so I'll throw it here as I'm coding in C#, although that doesn't really matter. I'm using .NET 4, trying to add a reference to mshtml, and I want to have all the capabilities depending on the version the client has installed. If I add a reference to the COM component called 'Microsoft HTML Object Library', the reference is labelled "MSHTML" and the path points to an assembly in the GAC called 'Microsoft.html' for some reason. Even though I have IE8 installed, it is still missing the IE8 interfaces, which makes me think it is just pointing to the Microsoft.html.dll wrapper instead of generating the reference from the actual COM compoment. The Microsoft.html.dll wrapper is missing the IE8 interfaces, and from what I can tell, this wrapper is somewhat unnecessary with the .NET 4 "Embed Interop Types" feature. The other thing that scares me is the "Specific Version" field on the reference, which is set to true, and I can't change it. What if someone has a lower version of "Microsoft HTML Object Library" than my dev machine? EDIT: Sorry, got a little confused between adding a reference to Microsoft.mshtml .NET assembly and directly to the COM component.  If I add the reference to the COM component, "Specific Version" isn't available in the properties, bu
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend