function setMenu(param1, param2){
if(param2 === undefined){
param2 = -1;
}
//Code
}
You can call this function in multiple ways:setMenu(0, 5); setMenu(0); //Param2 will be set to '-1' by the functionAnd both will work.
function setMenu(param1, param2){
if(param2 === undefined){
param2 = -1;
}
//Code
}
You can call this function in multiple ways:setMenu(0, 5); setMenu(0); //Param2 will be set to '-1' by the functionAnd both will work.
<Grid.Resources>
<Style x:Key="CategoryLegendItem" TargetType="toolkit:LegendItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="toolkit:LegendItem">
<StackPanel Orientation="Horizontal">
<Rectangle Width="8" Height="8" Fill="{Binding Background}" Stroke="{Binding BorderBrush}" StrokeThickness="1" Margin="0,0,3,0" />
<HyperlinkButton Content="{TemplateBinding Content}" Click="HyperlinkButton_Click" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
Notice how I replaced the default Title element that displays the legend item text by a HyperlinkButton. That way it actually looks like something that can be clicked. This button also triggers the click event.series.LegendItemStyle = (Style)LayoutRoot.Resources["CategoryLegendItem"]Finally there's the HyperlinkButtons click handler.
private void HyperlinkButton_Click(object sender, RoutedEventArgs e) {
RowPrestation row = (RowPrestation)((sender as HyperlinkButton)
.DataContext as PieDataPoint).DataContext;
PieSeries series = (PieSeries)(Chart.Child as Chart).Series[0];
series.SelectedItem = row;
}
Notice that the DataContext of the HyperlinkButton contains the PieDataPoint — in case of a pie chart — that goes with the legend item in question. And if you cast it, that points DataContext contains the bound object that was used as ItemsSource. Mine was a List<RowPrestation>.
ViewBag.DataFilter = new JavaScriptSerializer().Serialize(filter);Where filter is the object.
//Parse
parser = document.createElement('div');
parser.innerHTML = '@(ViewBag.DataFilter)';
var DataFilter = $.parseJSON(parser.innerHTML);
//Test
alert(DataFilter.Fields[0].FieldName);
And that's all there's to it.
[WebMethod]
public WebServiceResponse CallService(string name,
string url,
string method,
string contentType,
string postData) {
WebServiceResponse result = new WebServiceResponse();
try{
//Convert the post data into a byte array
//The post data is a string like "username=EGS&password=305"
byte[] data = null;
if (!string.IsNullOrEmpty(postData))
data = Encoding.UTF8.GetBytes(postData);
//Create the request and write the post data to it if any
WebRequest request = WebRequest.Create(url);
if (!string.IsNullOrEmpty(method))
request.Method = method;
if (!string.IsNullOrEmpty(contentType))
request.ContentType = contentType;
if (data != null) {
request.ContentLength = (long)data.Length;
using (Stream stream = request.GetRequestStream())
stream.Write(data, 0, data.Length);
}
else
request.ContentLength = 0L;
//Get the response from the web service
using (WebResponse response = request.GetResponse())
using (StreamReader reader =
new StreamReader(response.GetResponseStream())) {
result.StatusCode =
(int)(response as HttpWebResponse).StatusCode;
result.StatusDescription =
(response as HttpWebResponse).StatusDescription;
result.Content = reader.ReadToEnd();
}
}
catch (Exception ex) {
result.Error = "Error: [DashboardService.CallService] " + ex.Message;
}
return result;
}
WebServiceResponse is a custom class with the properties StatusCode, StatusDescription, Content and Error.
List<Customer> list = (from r in dataTable.AsEnumerable()
select new Customer {
Id = r.Field<int>("Id"),
Name = r.Field<string>("Name"),
Created = r.Field<datetime>("Created")
}).ToList();
List<string> columnNames = (from c in dataTable.Columns.Cast<datacolumn>()
select c.ColumnName).ToList();
public class BindableColumnHeader : BehaviorIt needs that .dll from before.{ public object Header { get { return GetValue(HeaderProperty); } set { SetValue(HeaderProperty, value); } } public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("Header", typeof(object), typeof(BindableColumnHeader), new PropertyMetadata( new PropertyChangedCallback(HeaderBindingChangedHandler))); private static void HeaderBindingChangedHandler( DependencyObject o, DependencyPropertyChangedEventArgs e) { var behave = o as BindableColumnHeader; if (behave != null && behave.AssociatedObject != null) behave.AssociatedObject.Header = e.NewValue; } protected override void OnAttached() { if (this.AssociatedObject != null) this.AssociatedObject.Header = this.Header; base.OnAttached(); } }
<data:datagridtextcolumn binding="{Binding Customer}">
<i:interaction.behaviors>
<synbus:bindablecolumnheader header="{Binding Whatever}" />
</i:interaction.behaviors>
</data:datagridtextcolumn>