среда, 25 мая 2011 г.

How to force the ObservableCollection to notify change when a property of an item changes


To make the DataGrid refresh automatically when the property values of data items in the data source are changed, the data item should implement the INotifyPropertyChanged interface. The collection does no need to notify property change at all. For example:
class SomeClass:INotifyPropertyChanged
{
     public event PropertyChangedEventHanlder PropertyChanged;
     private void OnPropertyChanged(string prop)
     {
          if(PropertyChanged!=null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(prop));
          }
     }
     private string name;
     public string Name
     {
          get {return name;}
          set
          {
              if(name!=value)
              {
                  name=value;
                  OnPropertyChanged("Name");
               }
           }
       }
  }
Hope this helps.

среда, 4 мая 2011 г.

Best Way to Register jquery and other scripts in asp.net pages


This time I want to explain the best way to register scripts in asp.net pages using the script manager. If you need to know what is the script manager go to script manager Overview.
Here the code for register.
<asp:ScriptManager ID="ScriptManager1" runat="server">
      <Scripts>
          <asp:ScriptReference 
Path="jquery/jquery-1.3.2.js" 
ScriptMode="Release" />
          <asp:ScriptReference 
Path="jquery/ui/ui.core.js" 
ScriptMode="Release" />
          <asp:ScriptReference 
Path="jquery/ui/ui.datepicker.js" 
ScriptMode="Release" />
          <asp:ScriptReference 
Path="jquery/jquery.jqURL.js" 
ScriptMode="Release" />
      </Scripts>
  </asp:ScriptManager> 
Remeber put this code inside form tag.
any suggestion leaves a comment.
good luck.