Wednesday, May 16, 2012

Refresh Rad Grid After Save Button Clicked 

Here is a sample code when save button is clicked then it refreshes the RAD Grid.

I am gonna put RAD Grid in panel.


<asp:Panel runat="server" ID="UsersPanel">
        <telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid_Users" PageSize="10" AllowCustomPaging="true"
            EnableViewState="true" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"
            runat="server" Skin="Vista"
            OnNeedDataSource="RadGrid_Users_OnNeedDataSource">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <GroupingSettings CaseSensitive="false" />

 <MasterTableView TableLayout="Fixed" DataKeyNames="User_id">

<NoRecordsTemplate>
                    <div>
                        No records to display.</div>
                </NoRecordsTemplate>
 <Columns>

<telerik:GridNumericColumn Aggregate="Count" HeaderText="User_id" DataField="User_id"
                        UniqueName="Customer_id" SortExpression="User_id" HeaderStyle-Width="50px" FilterControlWidth="50px"
                        AutoPostBackOnFilter="true" CurrentFilterFunction="equalto" ShowFilterIcon="true" FilterListOptions="VaryByDataType"
                        Display="false">
                    </telerik:GridNumericColumn>

 <telerik:GridBoundColumn HeaderText="Navn" DataField="Name" UniqueName="Name"
                        SortExpression="Name" HeaderStyle-Width="120px" FilterControlWidth="100px" FilterListOptions="VaryByDataType"
                        AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="true">
                    </telerik:GridBoundColumn>

 </Columns>
            </MasterTableView>
            <ClientSettings EnablePostBackOnRowClick="true">
                <Selecting AllowRowSelect="True" />
            </ClientSettings>
        </telerik:RadGrid>      
        </asp:Panel>


  <telerik:RadButton ID="Button_Save" runat="server"  Text="Gem" Width="125px" OnClick="Button_Save_Click"
                        Skin="Office2007" />


In RadAjaxManager  define which control you want to update.Here give Control ID of panel.








<telerik:RadAjaxManager ID="RadAjaxManager1"  EnableAJAX="true"  runat="server" >
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="UsersPanel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="UsersPanel"  LoadingPanelID="RadAjaxLoadingPanel1"/>
                   
                    </UpdatedControls>
                </telerik:AjaxSetting>


<telerik:AjaxSetting AjaxControlID="Button_Save" >
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="UsersPanel" LoadingPanelID="RadAjaxLoadingPanel1"/>                    
                    </UpdatedControls>
                </telerik:AjaxSetting>


 </AjaxSettings>
 <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />

</telerik:RadAjaxManager>      
     
        <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1"
            Skin="Windows7" Transparency="20" />



<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function RequestStart(sender, eventArgs) {
                    var eventTarget = eventArgs.get_eventTarget();
                    if (eventTarget.indexOf("Button_Save_Click") != -1) {
                        eventArgs.set_enableAjax(false);
                    }

                }
                function ResponseEnd(sender, eventArgs) {
                }
            </script>
        </telerik:RadCodeBlock>


Have Fun ;)





Tuesday, April 24, 2012

Differnce between new and override

It is asked very frequently, that how can we call the parent version of a method in inheritance. In C# we can use new keyword to define a new method in child class and get this effect. I have mentioned a little example that will illustrate you the difference between override and new keyword :


//Calls Base class function 1 as new keyword is used.

BaseClass bd = new DeriveClass();

bd. function ();



//Calls Derived class function 2 as override keyword is used.

BaseClass bd2 = new DeriveClass();

bd2. function ();




Thank You. Happy coding....

Tuesday, April 17, 2012

Drag Events on IOS Devices using JQuery

These issues arise many times when you create a site e.g. on Asp.net with JQuery and some of the events doesn't work at all... Events like Drag drop, double click gestures.... 

We will talk about drag drop events in this case. Assuming that Drag drop events are working perfecting fine on the normal system browsers, here is the way to make it work for smart devices and tablets.

1. Add "touch-punch.min.js" file on your project.
2. Add the following line on your aspx page or control:

<script src="jquery.ui.touch-punch.min.js"></script>
 
3.  Now just add this line on the script portion

<script>
$('#widget').draggable();
</script>
 
 
That's it. You just need to add few lines and your website will now support drag drop gestures
on an iPhone/iPad/iPodTouch. 
 
 Happy coding!!!
 
Click on this link to download the script. 

Thursday, April 12, 2012

Images are not appearing in IIS 7-7.5

Today I have found a funny issue in my asp.net site deployment in IIS 7 on windows server 2008. After deploying my site, I was unable to see images. Initially, I though its a permission issue. I gave IIS_IUSR permission to deployment directory but nothing happened. I tried to reconfigure i.e. broswer settings but nothing turns in my way.

After that I started doing some RND towards IIS settings. I was amused to identify that in IIS, I didn't check static content under WWW Services and it was the reason that my images are not appearing. After enabling the following setting the images started appearing.I hope it would be helpful for you guys.. :)

Earn Money ! Affiliate Program
Open Directory Project at dmoz.org