locked
Different actions in a button that will depend on what is in a text box RRS feed

  • Question

  • Hello , I'm beginning to use Expression Blend now and i want to design a login page of a site but I don't know how to put  different actions  on a button depending on what is written in the text box.

    example:

    If the User type "admin" on the text box: the button leads to admin's page

    If the User type "User" : the button  the button leads to User's page

     

    Thursday, December 8, 2011 3:00 PM

Answers

  • Good to know, I was just pointing it out :)

    How are you navigating to the new page?

     

    One way that should be relatively easy to do what you want is to use conditional triggers combined with actions.

    An example that is conditional on the value of a textbox is:

    <Button Margin="191,200,189,106">
    			<i:Interaction.Triggers>
    				<i:EventTrigger EventName="Click">
    					<i:Interaction.Behaviors>
    						<ei:ConditionBehavior>
    							<ei:ConditionalExpression>
    								<ei:ComparisonCondition LeftOperand="{Binding Text, ElementName=textBox}" RightOperand="admin"/>
    							</ei:ConditionalExpression>
    						</ei:ConditionBehavior>
    					</i:Interaction.Behaviors>
    					<ei:SetDataStoreValueAction/>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    		</Button>
    

    This was created by doing the following:

    1. Drag an action from the asset panel onto an object, select the action in the timeline panel
    2. In the properties panel, expand the conditions section, add a condition
    3. For the first value, click the small square next to the value box, select element property binding, click on the textbox that has the source value, select Text
    4. Fill in the comparison value
    5. Set up the resulting action (this is where your answer to my question about how you are navigating will come into play)

     

    This action will only fire when that condition is met.

    • Proposed as answer by Brian Hilstrom Thursday, December 8, 2011 8:50 PM
    • Marked as answer by felipe12345 Tuesday, December 20, 2011 10:37 PM
    Thursday, December 8, 2011 8:08 PM
    Moderator

All replies

  • What platform are you using? WPF, Silverlight or Windows Phone?

    Is the login authentication handled inside the app? Generally for security purposes such authentication is handled on a secured server side someplace else, outside of the control of a possibly malicious user.

    • Marked as answer by felipe12345 Thursday, December 8, 2011 5:09 PM
    • Unmarked as answer by felipe12345 Thursday, December 8, 2011 5:09 PM
    Thursday, December 8, 2011 3:57 PM
    Moderator
  • I'm using WPF.

    well, I'm just building a prototype that will be used to guide us during the developmento of the site.

    Thus we are considering the hypothesis that  everything should go as planned, so malicious users aren't being considered (but They will be on the real project)



    • Edited by felipe12345 Thursday, December 8, 2011 10:32 PM
    Thursday, December 8, 2011 5:48 PM
  • Good to know, I was just pointing it out :)

    How are you navigating to the new page?

     

    One way that should be relatively easy to do what you want is to use conditional triggers combined with actions.

    An example that is conditional on the value of a textbox is:

    <Button Margin="191,200,189,106">
    			<i:Interaction.Triggers>
    				<i:EventTrigger EventName="Click">
    					<i:Interaction.Behaviors>
    						<ei:ConditionBehavior>
    							<ei:ConditionalExpression>
    								<ei:ComparisonCondition LeftOperand="{Binding Text, ElementName=textBox}" RightOperand="admin"/>
    							</ei:ConditionalExpression>
    						</ei:ConditionBehavior>
    					</i:Interaction.Behaviors>
    					<ei:SetDataStoreValueAction/>
    				</i:EventTrigger>
    			</i:Interaction.Triggers>
    		</Button>
    

    This was created by doing the following:

    1. Drag an action from the asset panel onto an object, select the action in the timeline panel
    2. In the properties panel, expand the conditions section, add a condition
    3. For the first value, click the small square next to the value box, select element property binding, click on the textbox that has the source value, select Text
    4. Fill in the comparison value
    5. Set up the resulting action (this is where your answer to my question about how you are navigating will come into play)

     

    This action will only fire when that condition is met.

    • Proposed as answer by Brian Hilstrom Thursday, December 8, 2011 8:50 PM
    • Marked as answer by felipe12345 Tuesday, December 20, 2011 10:37 PM
    Thursday, December 8, 2011 8:08 PM
    Moderator
  • I used the SketchFlow Map to create pages and NavigateToScreenAction to build the navigation. I would like to use HyperlinkAction  but I was having The Following problem: "Resource cannot be found".
    After thinking a little, with the help that you gave me, I finally managed to solve my problem ! 
    Thank you very much, I really appreciate your help.

    • Edited by felipe12345 Tuesday, December 20, 2011 10:50 PM
    Tuesday, December 20, 2011 10:49 PM