Click here to Skip to main content
13,000,569 members (61,427 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am getting this error while using
((System.Web.UI.WebControls.Label)this.Master.FindControl("lblErr")).Text = "";

means i am calling Master page Label but when i am accessing Asp pages from Client i am getting ths error but on server its run perfectly

[A]ASP.site_master cannot be cast to [B]ASP.site_master. Type A originates from 'App_Web_bwoe4mfw, Version=, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\erp\5c2ea699\4c38a279\App_Web_bwoe4mfw.dll'. Type B originates from 'App_Web_zco24bnv, Version=, Culture=neutral, PublicKeyToken=null'
Posted 6-Jan-13 23:56pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


You can create a property or method in master page that will take a string parameter and set it as a text to the error label control.

and then you can call that method from inside the content page code.


Define a method in Master page like :

public void SetError (string ErrorMsg)
     lblError.Text = ErrorMsg;

and in content page set the message by calling this method as :

this.Master.SetError("Error Message Here");

To be able to access master page's methods or properties you have to define the master type in the page's aspx code as follows:

<%@ MasterType VirtualPath="~/MasterPage.master" %>
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

When this happened to me, I had already done the things @Er-Gayatri had suggested above, and the page had been working, literally for years, as it was.

I just had to "Rebuild All" and restart Visual Studio and it started doing it right again. Not sure the rebuild was even necessary.

I'm guessing that the currently running instance of VS had a reference in its debug whatever to a generated asp.NET dll that it forgot to update after the dll had been regenerated at some point, and needed to reboot to sort it out.
"What good is it to know that you've forgotten something when you cannot remember what it is that you've forgotten?"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 25 Aug 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100