Update a webapplication on fly without giving any errors.
Hello all,
How can i update the new pages to push to server without knowing to clients. I get some error messages when the new version is pushed to server if there is any page open in client machine.
Errog msg : "Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back"
Thanks
Vishwas
Answers (2)
1
Hey
As your base class is Player which was derived by Warrior and Sorcerer class, just cast your Player class to the respective derive class to access its field.
- static void Main(string[] args)
- {
- var player = ChooseClass();
- if(player is Warrior)
- {
- var cType = ((Warrior)player).classtype;
- }
- else
-
- Console.Clear();
- Console.WriteLine();
- Console.ReadLine();
- }
Hope that works !
1
change this line
- Player player = ChooseClass();
to:
- var player = ChooseClass();
once you know by gettype which type of object is created, then you can write the logic accordingly
0
Hi Nilesh,
I've switched type Player to var in the main method, but I'm still in the same situation because the return type of the method is still Player, and it won't accept var as the return type. Therefore, I still can't access the fields of the Warrior/Sorcerer class because it thinks its just a Player.