31 August 2009

Download jQuery 1.3 Cheat Sheet from http://oscarotero.com/jquery/

jQuery

it is also link to its example.

28 August 2009

I few months a go have posted about some WYSIWYG editor, I have come to know that there is one more tool next generation solution of FCK Editor.

Almost all developers knows about FCK Editor, Now there is a new version, CK Editor.

ckEditor

There is all features of FCK editor and dozens of new functionality. CK Editor is faster is fast to load and fast to use.Its current version is 3.0

See demo here.

24 August 2009

I have seen many times that Thickbox normal works with <a href=””></a> syntax,

Ex :

Inner Page Content Syntex :

<a href="#TB_inline?height=200&width=200&inlineId=hiddenModalContentID&modal=true"
class="thickbox">Click here to show hidden modal content.</a>

IFrame Syntex :


<a href="testPage.aspx?keepThis=false&TB_iframe=true&height=200&width=200"
title="saActionPage" class="thickbox">Click here</a>  

But what happen when you need to open ThickBox by click event? Here is its solution.


You can to use same syntax of HREF  with “tb_show” function.


Ex :


<script language="javascript" type="text/javascript">

    function showTB()  {

       var newURL = "#TB_inline?height=200&width=300&inlineId=hiddenModalContentID";

        tb_show("ThickBox Title Here", newURL);

    }

</script>


It means you can also open thick box by any other event also.

18 August 2009

Last Month I posted that How to export to excel from web page with data formatting.

But when you are trying to export entire grid specially with Boolean datatype column,

 

               string attachment = "attachment; filename=Registration.xls";
               Response.ClearContent();
               Response.AddHeader("content-disposition", attachment);
               Response.Charset = "";
               //set the Response mime type for excel
               Response.ContentType = "application/vnd.ms-excel";
               //create a string writer
               System.IO.StringWriter stringWrite = new System.IO.StringWriter();
               //create an htmltextwriter which uses the stringwriter
               System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
               //instantiate a datagrid
               GridView dg = new GridView();
               dg.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound);
               //set the datagrid datasource to the dataset passed in
               dg.DataSource = dt;
               //bind the datagrid
               dg.DataBind();
               //dg.Columns[1].ItemStyle.
               //tell the datagrid to render itself to our htmltextwriter
               dg.RenderControl(htmlWrite);
               //all that's left is to output the html
               Response.Write(stringWrite.ToString());
               Response.End();

 

its result:

export check box

You can see that checkbox is there, But this is not user friendly. because in excel operator are not familiar with check box in excel data.

It means there should be 1/0  or True/False in place of checkbox. lets see.

Add RowDataBound event to the grid…

 

               GridView dg = new GridView();
               dg.RowDataBound += new GridViewRowEventHandler(GridView1_RowDataBound);

 

Now create an event…

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        CheckBox chk = (CheckBox)e.Row.Cells[1].Controls[0];
        chk.Visible = false;
        if (chk.Checked)
        {
            e.Row.Cells[1].Text = "1";
        }
        else
        {
            e.Row.Cells[1].Text = "0";
        }

    }
}

You can see that now checkbox is invisible and we are writing 1 or 0 in the same cell, Cells[1] is static value for second column.

and now see the result…

export 01

You can see that value is now changed in to 1 inplace of checkbox.

We can change any kind of data by using RowDataBound event.