I am working on silverlight web application (RIA) hosted on to a silverlight web application.
Background: I have a stackpanel in one of the xaml pages. I tried to simplify my problem. It is down as follows:
My xaml page has a stack panel and that stackpanel has only textblock and button in it. only authorized users can see the value in the textblock, when navigated to the xaml page. If the user is unauthorized, I am planning to show "unauthorised" message (instead of value) in the textblock (button is also collapsed. I dont show button.)
FYI, this value of texblock comes from a WCF service and i have made proper attributes for authorization in the service. If unauthorized, value will not come to textblock from service. What I am doing now, is just for UI, when some user tries to enter the url of the page from browser's address bar I want to show him the unauthorised message.
What have I done so far:: I gave a name to stackpanel. I gave a name to textblock and a name to button. if authorized, I am setting the text value of text block to the service returned value.
If unauthorized, I am changing the visibility and text from .cs file as this.
textblock.Text="unauthorized";
buttonname.Visibility = Visibility.Collapsed;
Problem: Problem is I got an idea. :( When I have a name for my stackpanel, I can say stackpanelname.Visibility = Visibility.Collapsed;
But I cannot show my message (Textblock) now, coz child controls are also collapsed with parent. Is there any way that, I can collapse my stackpanel (parent control), but only one control of it (one child control, or few) is visible.
Solutions: As I am typing this, I got a solution, I can go for a new stack panel, with a text block, whose visibility I can set to VISIBLE and text as my message. But, is it the only way.? How do we handle these situations?
In general, presuming my question is clear, what is general approach to provide security in this kind of scenarios, from UI. Is it gonna be redirecting to error page/login page or a message to user on the same page or any other thing. Presuming, Backend services, will be having attributes and logic for authorizations.