This post has been migrated from www.experimentsincode.com, we apologise if some of the images or content is missing

This post has been migrated, original date 10 Sep 2008

Today I wanted a popup to appear in my XAML application and ask the user for some info before disappearing. This seemed like a simple requirement but it took some hunting around to find the code to do this so here is the solution.

In this example the prompt pops up when the user clicks a button within the XAML application. This is handled by the ButtonClick method. Once clicked this calls a Pipeline method, notice how I have to define the method I want to call as a string, I wish Sitecore would use delegates.

Within the pipeline method you need to check the args.IsPostBack to see if the prompt has been opened yet.

17 [HandleMessage("local:MyButtonClick")]

18 public void ButtonClick(Message message)

19 {

20 Sitecore.Context.ClientPage.Start(this, "PopupTagPipeline");

21 }

22

23 public void PopupTagPipeline(Sitecore.Web.UI.Sheer.ClientPipelineArgs args)

24 {

25 if (args.IsPostBack)

26 {

27 // this event occurs after the user has entered some data

28 string result = args.Result;

29

30 //do some more work

31 }

32 else

33 {

34 //prompt the user to enter a value and then wait for their response.

35 global::Sitecore.Context.ClientPage.ClientResponse.Input("Please enter a value", "");

36 args.WaitForPostBack();

37 }

38 }

The prompt takes two arguments, the first is the label to display to the user and the second is the default value.

Once this is complete you should end up with a nice prompt.

comments powered by Disqus