Wednesday, April 3, 2013

Jquery basics

Jquery Reference Links:
=================

Jquery UI:
------------
http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css
http://code.jquery.com/ui/1.10.2/jquery-ui.js

Jquery:
---------
http://code.jquery.com/jquery-1.9.1.js

How to use page_init event(page loaded) in jquery:
=====================================
This will be used to execute initial script after complete page render. There are many ways available use page_init event in client side from that the following:
$(document).ready(function() {
    // put all your Javascript/jQuery script in here.
});

$(function(){

    // put all your Javascript/jQuery script in here.
});

How to access element by using "Id" attribute:
------------------------------------------------------
<div id="dvmyelement" > Access element by using "Id" attribute: </div>

var myelement = $("#dvmyelement");



Thursday, February 28, 2013

How find html tag and remove it from string in C#

     

How find html tag from string in C#
=========================

   Situation: i want to find and remove all the javascript from mystring. which can be like

<script  type="text/javascript" id="someid">

.......Some functions goes here

</script>

Now i want to remove all the script content from my string. The best way to remove script content is by using  Regularexpression

            Regex reg=new Regex("<script (.+?)</script>");
            reg.Replace(test, "");

Example:
======

 string test = "<script type='text/javascript'> Some functions goes here </script> A C# string is an array of characters declared using the string keyword. A string literal is declared using quotation marks, as shown in the following example:   ";
            test += " <br/> You can extract substrings, and concatenate strings, like this:";
            test += "<script> another text </script> <br /> String objects are immutable, meaning that they cannot be changed once they have been created. Methods that act on strings actually return new string objects. In the previous example, when the contents of s1 and s2 are concatenated to form a single string, the two strings containing \"orange\" and \"red\" are both unmodified. The += operator creates a new string that contains the combined contents. The result is that s1 now refers to a different string altogether. A string containing just \"orange\" still exists, but is no longer referenced when s1 is concatenated.";
            Regex reg=new Regex("<script (.+?)</script>");

            reg.Replace(test, "");

response.write(test);

Wednesday, February 27, 2013

How To Date filter with Devexpress XPO XPDataView



How To Date filter with Devexpress XPO XPDataView




 public string GetCreatedDate(string period, string column, string customFilterFrom = null, string CustomFilterTo = null)
        {

            string date = string.Empty; string filterexp = string.Empty;
            DateTime dt = DateTime.Today;
            switch (period.ToUpper())
            {

                case "CUSTOM":
                    date = new BetweenOperator(column, Convert.ToDateTime(customFilterFrom.Replace("/", "-")),       Convert.ToDateTime(CustomFilterTo.Replace("/", "-"))).ToString();

                    break;
                case "TODAY":
                    date = new BetweenOperator(column, dt, dt.AddDays(1)).ToString(); //string.Format("[{1}] = #{0}#", dt, column);//.ToString("MM/dd/yyyy")
                    break;
                case "LASTDAY":
                     date = new BetweenOperator(column,dt.AddDays(-1),dt).ToString();
                    break;
                case "THISYEAR":
                    date = new BetweenOperator(column, new DateTime(DateTime.Now.Year, 4, 1), dt.AddDays(1)).ToString();
                    break;

                case "THISMONTH":
                    date = new BetweenOperator(column, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1), dt.AddDays(1)).ToString();
                    break;
                case "LASTMONTH":
                    date = new BetweenOperator(column, new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(-1), new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddDays(-1)).ToString();
              
                    break;
                case "THISWEEK":
                    int days = (DateTime.Now.DayOfWeek - DayOfWeek.Sunday) - 1;
                    DateTime thisweek = DateTime.Now.AddDays(-(days));
                    date = new BetweenOperator(column, thisweek, thisweek.AddDays(days)).ToString();
                    break;
                case "LASTWEEK":
                    int diff = (DateTime.Now.DayOfWeek - DayOfWeek.Sunday) + 6;
                    DateTime mondayOfLastWeek = DateTime.Now.AddDays(-diff);
                    date = new BetweenOperator(column, mondayOfLastWeek, mondayOfLastWeek.AddDays(diff -6)).ToString();
                     break;
                default:
                    date = string.Format("[{0}] = '{1}'", column, period);
                    break;

            }
            return date;
        }



Refer my original post in devexpress : Unable to filter date values in xpo DataSource

Thursday, November 29, 2012

Free Heart Surgery for children

Free Heart Surgery for children



Source : https://www.facebook.com/photo.php?fbid=409587672445200&set=a.152699364800700.37093.151360824934554&type=1&theater

Wednesday, August 22, 2012

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. in Server

There are times when the coexistence of 64 and 32 bit code on the same machine can cause all sorts of seemingly strange issues.
One of them just occurred to me while trying to run the ASPx demos from Developer Express, my main provider of .Net components (the best supplier I’ve ever been able to find).
I was getting the following error:
The ‘Microsoft.Jet.OLEDB.4.0′ provider is not registered on the local machine:
Server Error
It may look otherwise, but this error is generally due to either of two thing:
  • you don’t have Office 2007/2010 Jet drivers installed
  • or you are running a 32 bit application in a default x64 environment.
The first issue is easy to solve, just download the Access 2010 Database Engine from Microsoft (works with Access 2007 databases as well).
For the second one, the fix is also easy enough:
  • For Windows 2008: Navigate to Server Manager > Roles > Web Server (IIS) > Internet Information Services (IIS) Manager, then look under your machine name > Application Pool.
  • For Windows 7: Navigate to Programs > Administrative Tools > Internet Information Services (IIS) Manager, then look under your machine name > Application Pool.
Under there you can call the DefaultAppPool’s advanced settings to change Enable 32-Bits Applications to True:

Advanced Settings
You may have to restart the service for it to take effect but it should work.

Source: http://blog.nkadesign.com

Friday, July 27, 2012

How to show aspxpopup control on button click instead of enter key press

Steps:
====
1. I have two textboxes  and one button and one aspxpopupcontrol in a aspxwebpage
 2. I attached  Keypress event for two textboxes and i have attached button OnClientClick event from C# code behind to show aspxpopupcontrol.
3. Here problem is when ever i enter some data in any one of the text and press enter it is executing textbox keypress event as well as it showing aspxpopupcontrol. it very annoying to the user.
4. I resolved this issue by using the following devexpress client side method  in textbox keypress event.
                       ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);

 Example:
========

  <dx:ASPxTextBox runat="server" ID="txtSearch" ClientInstanceName="txtSearch" NullText="Search by Text"  Style="border-radius: 4px 4px 4px 4px;">
  <ClientSideEvents  KeyPress="function(s,e){ 
                                                                var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
                                                                if(keypressed ==13)
                                                                  {
                                                                        //Your client side functionality goes here
                                                                        ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
                                                                  }}" />
  </dx:ASPxTextBox>

<dx:ASPxTextBox runat="server" ID="txtTagSearch" ClientInstanceName="txtTagSearch" NullText="Search by Tag"  Style="border-radius: 4px 4px 4px 4px;">
  <ClientSideEvents  KeyPress="function(s,e){ 
                                                                var keypressed=ASPxClientUtils.GetKeyCode(e.htmlEvent);
                                                                if(keypressed ==13)
                                                                  {
                                                                        //Your client side functionality goes here
                                                                        ASPxClientUtils.PreventEventAndBubble(e.htmlEvent);
                                                                  }}" />
  </dx:ASPxTextBox>

 <asp:ImageButton ID="btnShowCustomViewBuilder" CausesValidation="true" runat="server" ImageUrl="~/Styles/Images/FilterIcon.png"
                                                         OnClientClick=" popup.Show();  return false"    />

<dx:ASPxPopupControl ID="AspxPopupControl1" runat="server" Modal="True" AutoUpdatePosition="true" HeaderStyle-Font-Bold="true"
    PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" AllowDragging="true" AccessibilityCompliant="false" 
    ShowLoadingPanel="false" HeaderText="Example Popup" ClientInstanceName="popup"  PopupAction="LeftMouseClick" 
    Width="520px">
    <ContentCollection>
        <dx:PopupControlContentControl ID="PopupControlContentControl3" runat="server" SupportsDisabledAttribute="True">

<table>
<tr>
<td> //Your content goes here  </td>
</tr>
</table>

  </dx:PopupControlContentControl>
    </ContentCollection>
</dx:ASPxPopupControl>


Reference to resolve above issue

Please let me know if you have any doubts on this.

Monday, July 23, 2012

How to Display row value as Column Name in SQL Server

Static Query:
=========

SELECT branch1,branch2,Name,Id  FROM (SELECT top 5   tb.*    from  Users as tb
  ) AS PivotData
PIVOT (COUNT(Location) FOR   Branch  IN (branch1,branch2) ) AS PivotTabllumns


Dynamic Query:
============


  'SELECT *  FROM (SELECT top 5  tb.* from  ' +  TableName  + ' as tb
) AS PivotData
PIVOT (COUNT(' +  Columns +') FOR  ' +  Columns +' IN ( ' + CColumns + ') ) AS PivotTable'


///Above Columns and CColumns and TableName are the local variables  which are picked from temp table

Instead of "TableName" value you need to pass your table name
Instead of "Columns" On which column(ex: ID,Reference No or any column etc....) you need to perform operation
Instead of "CColumns" you have to pass your own values ex: if your checking for branch count  you need to pass branch name values i.e: branch1, branch2, branch3

If you have any doubts please let me know.

Result :
=======