Thursday, July 24, 2008

jQuery - Thickbox

http://jquery.com/demo/thickbox/

http://blogs.digitss.com/javascript/hacking-jquery-thickbox/

Conditional statement for IE6

<!--[if lt IE 7]>
  <link rel="stylesheet" type="text/css" media="screen" href="other.css" />
<![endif]-->

lt - means "less then" - will link another css only for browsers less then IE7

Track mouse with jQuery

 

$(document).ready(function()
 {
  $().mousemove(function(e)
   {
    $('p').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);
  });
});

 

Source

Saturday, July 19, 2008

ASP.NET: Retrieve data from a web page

Link

ASP.NET: Custom Error Pages

Link

ASP.NET: Extract data from a SQLDataSource to a DataTable

 

1. Dim dv As New System.Data.DataView  
2. Dim dt As New System.Data.DataTable  
3. dv = mySQLDataSource.Select(DataSourceSelectArguments.Empty)  
4. dt = dv.ToTable()
Source

ASP.NET: Use C Sharp and VB.NET in the same project

 

Link

Persisting data in a web app by using frames

 

Say you have your main page, which is just a frameset. All the navigation occurs within that frameset, such that going from page1 to page2 merely updates the frame's url, it doesn't re-create the host page. This leaves the host page intact, including it's JavaScript state. Therefore, you could have a JavaScript variable persist data between pages.

<html>
  <head>
    <title>My App</title>
    <script language="javascript" type="text/javascript">
      var _javaScriptVar = null;
    </script>
  </head>
  <frameset>
      <frame src="Page1.aspx" id="mainFrame">
  </frameset>
</html>

 

You could then reference this variable from your child pages via the DOM:

window.parent._javaScriptVar = "someValue";

 

Source

Jump between braces in Visual Studio

Put your cursor before or after the brace (your choice) and then press Ctrl+].

Source

Wednesday, June 25, 2008

GridView ObjectDataSource Paging

Took me a lot of time to figure it out...

First, paging doesn't seem to work when ObjectDataSource Select function returns SqlDataReader so it returns DataView now.

The code looks like this:

   1: [DataObjectMethod(DataObjectMethodType.Select)]
   2:     public static DataView GetRows(int statusid, int experienceid, string submitter, string idsid, string SortExpression)
   3:     {
   4:  
   5:         StringBuilder strSql = MainSelectSql(idsid, statusid, experienceid, submitter, SortExpression);
   6:  
   7:         SqlConnection connection = Connection.GetConnection();
   8:         SqlCommand command = new SqlCommand(strSql.ToString(), connection);
   9:         command.CommandType = CommandType.Text;
  10:         SqlDataAdapter adapter = new SqlDataAdapter(command);
  11:  
  12:         //connection.Open();
  13:         DataTable dt = new DataTable();
  14:         adapter.Fill(dt);
  15:         connection.Close();
  16:         int totalRecords = dt.Rows.Count;
  17:  
  18:         DataView dw = new DataView(dt);
  19:  
  20:         return dw;
  21:     }

 

The GridView has to have its "AllowPaging" set to true and PageIndexChanging method looks like this:

   1: protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
   2: {
   3:     GridView gv = (GridView)sender;
   4:     gv.PageIndex = e.NewPageIndex;
   5:     gv.DataBind();
   6: }

 

Also can change the page size in properties...

Saturday, June 21, 2008

SQL Server 2005- OVER() partition

This will be useful for GridView pagination:

An aggregate functions can be added to any SELECT (even without a GROUP BY clause) by specifying an OVER() partition for each function.

This means that this code:

   1: select 
   2:     o.customerID, o.productID, o.orderDate, o.orderAmount, t.Total
   3: from 
   4:     Orders o
   5: inner join 
   6:    (
   7:     select customerID, sum(orderAmount) as Total from Orders group by customerID
   8:    ) 
   9:   t on t.customerID = o.customerID
can be replaced with:
   1: select customerID,  productID, orderDate, orderAmount, 
   2:       sum(orderAmount) OVER (Partition by CustomerID) as Total
   3: from Orders

Source

Monday, June 9, 2008

jQuery Selectors - How to Get Anything You Want

Great articles from Learning  jQuery blog:

How to Get Anything You Want - part 1

How to Get Anything You Want - part 2

Firefox popup blocker blocks ctrl-V from Google Reader

Found the solution on Google Groups (Google Reader Help):

1. In a Firefox window, enter "about:config" in the address bar.
2. In the "Filter" field, type "popup_maximum".
3. One preference, called "popup_maximum" appears; double-click the
"value" number.
4. Enter a new, appropriately large value. I used 2000, just to be on
the safe side.

Sunday, June 1, 2008

SQL - substring and charindex

 

   1: SELECT
   2:     substring(IdeaText,1,
   3:         charindex('//', IdeaText)
   4:     ) as part1
   5: FROM tblIdeas

 

substring

charindex