Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting this error while using
C#
((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=0.0.0.0, 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=0.0.0.0, Culture=neutral, PublicKeyToken=null'
Posted

hi,

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.

e.g.

Define a method in Master page like :

C#
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" %>
 
Share this answer
 
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.

[speculation]
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?"
[/speculation]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900