Monday, November 1, 2010

Using Hyperlink in client WPF application

 

As long as hyperlink is not in a page control, should handle “RequestNavigate”:

<TextBlock>
   <Hyperlink NavigateUri="http://www.google.com" RequestNavigate="Hyperlink_RequestNavigate">Click here!</Hyperlink>
</TextBlock>
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
{
   System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri));
   e.Handled = true;
}

Friday, April 23, 2010

jQuery $.ajax call with parameters

I always forget the exact syntax and waste time searching for an example on the web.

   1:  $.ajax({
   2:      type: "POST",
   3:      url: "Default.aspx/WebMethodWithParameters",
   4:      data: { param1: $('#val1').val(),
   5:              param2: $('#val2').val(),
   6:              param3: $('#val3').val()
   7:          },
   8:      success: function(msg) {
   9:          //on success callback
  10:      },
  11:      error: function(msg){
  12:          //on error callback
  13:      }
  14:  });

more info on the jQuery help page