Saturday, December 29, 2007

Top 5 SharePoint Resources to Bookmark

Top 5 SharePoint Resources to Bookmark from Arpan Shah's Blog

Besides Microsoft.com, MSDN and TechNet, here are 5 SharePoint resources I recommend bookmarking/subscribing to:

SharePoint Team Blog
http://blogs.msdn.com/sharepoint

SharePointPedia built on SharePoint technology! [new]
http://www.sharepointpedia.com

CodePlex
http://www.codeplex.com/Project/ProjectDirectory.aspx?TagName=Sharepoint
Community Kit for SharePoint (CKS)
Accessibility Kit for SharePoint (AKS)

SharePoint Community Portal
http://sharepoint.microsoft.com/sharepoint

SharePoint Forums
http://www.mssharepointforums.com

Thursday, December 20, 2007

determining whether your PC is running 32 bit OS or 64 bit OS

Now a days before installing microsoft product this is the common question just pop-up choose installation for 32-bit or 64-bit application... Well here a good article from Microsoft.

How to determine whether your computer is running a 32-bit version or a 64-bit version of the Windows operating system

Tuesday, December 18, 2007

Javascript Calling from Page behind in asp.net

Its a sample javascript which is called from page behind

In .Aspx File

<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">

function IsChecked(chkObj1,strText,strFormName)
{
if(strText == "")
return;

strText = strText.replace( '<b>', '');
strText = strText.replace( '</b>', '');

var chkObj = document.getElementById(chkObj1);
var txtObj = document.getElementById('<%= TextBox1.ClientID %>');
if(chkObj.checked == true) //For Adding Item
{
var iFormFound = 0;
var iTextFound = 0;
iFormFound = txtObj.value.search(strFormName);
if(iFormFound == -1)
{
//If Form Name is Not There Append it
if(txtObj.value.length == 0)
txtObj.value = txtObj.value + strFormName;
else
txtObj.value = txtObj.value + "\n\n" + strFormName;
}

//If Text Not There Append it After Form Name
iTextFound = txtObj.value.search(strText);
if(iTextFound == -1)
{
if(txtObj.value.length == 0)
{
//txtObj.value = strText;
var iIndexOf = txtObj.value.indexOf(strFormName);
iIndexOf = iIndexOf + strFormName.length;
//alert(iIndexOf);
var strBefore = txtObj.value.substr(0,iIndexOf);
var strAfter = txtObj.value.substr(iIndexOf,txtObj.value.length);
txtObj.value = strBefore + strText + strAfter;
//alert(strBefore + " => " + strText + " => " + strAfter + " => " + txtObj.value);
}
else
{
//txtObj.value = txtObj.value + "\n" + strText;
var iIndexOf = txtObj.value.indexOf(strFormName);
iIndexOf = iIndexOf + strFormName.length;
//alert(iIndexOf);
var strBefore = txtObj.value.substr(0,iIndexOf);
var strAfter = txtObj.value.substr(iIndexOf,txtObj.value.length);
txtObj.value = strBefore + "\n" + strText + strAfter;
//alert(strBefore + " => " + strText + " => " + strAfter + " => " + txtObj.value);
}
}

}
else //For Removing Item
{
var iTextFound = 0;
iTextFound = txtObj.value.search(strText);
if(iTextFound != -1)
{
txtObj.value = txtObj.value.replace( strText + "\r\n", '');
//For Last Element (Special Case)
if(txtObj.value.search(strText) != -1)
{
txtObj.value = txtObj.value.replace( strText, '');
txtObj.value = txtObj.value.substr(0,txtObj.value.length - 2);
}
}
}
}

</script>
</head>



In .Aspx.Cs File (asp.net Code behind file)

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ApplyJavascript();
}
}

private void ApplyJavascript()
{
CheckBox1.Attributes.Add("onClick", "IsChecked('" + CheckBox1.ClientID.ToString() + "','Group1','Checkbox1')");
CheckBox2.Attributes.Add("onClick", "IsChecked('" + CheckBox2.ClientID.ToString() + "','Group1','Checkbox2')");
CheckBox3.Attributes.Add("onClick", "IsChecked('" + CheckBox3.ClientID.ToString() + "','Group1','Checkbox3')");

CheckBox4.Attributes.Add("onClick", "IsChecked('" + CheckBox4.ClientID.ToString() + "','Group2','Checkbox4')");
CheckBox5.Attributes.Add("onClick", "IsChecked('" + CheckBox5.ClientID.ToString() + "','Group2','Checkbox5')");
CheckBox6.Attributes.Add("onClick", "IsChecked('" + CheckBox6.ClientID.ToString() + "','Group2','Checkbox6')");
CheckBox7.Attributes.Add("onClick", "IsChecked('" + CheckBox7.ClientID.ToString() + "','Group2','Checkbox7')");
}

Sunday, December 16, 2007

Visual Studio 2008 and .Net 3.5 Videos

Getting started videos for

  • Visual Studio 2008 Videos
  • .Net 3.5 Videos
  • Asp.net 3.5 Videos

http://asp.net/learn/3.5-videos/

This video series will also explain whats new feature in .Net 3.5

LINQ Videos and More...

LINQ Video Series

Part 1: Introduction to LINQ and SQL
Part 2: Defining our Data Model Classes
Part 3: Querying our Database
Part 4: Updating our Database
Part 5: Binding UI using the ASP:LinqDataSource Control
Part 6: Retrieving Data Using Stored Procedures
Part 7: Updating our Database using Stored Procedures
Part 8: Executing Custom SQL Expressions
Part 9: Using a Custom LINQ Expression with the control
LinqDataSource Technology Overview

Friday, December 14, 2007

Export datagrid to Excel in asp.net (Revised)

Previously I had Post for Export Datagrid Data to Excel

It was perfectly alright but following Article has added Advantage over the Previous Post.

  • You can able to Hide Few Fields and Display desired fields in Exported Excel Sheet, bydefault all the fields which are displayed in datagrid was displayed in Excel, but let say we want to hide "Edit" and "Delete" field while exporting datagrid data to excel. (Note: You can also use datagrid1.Columns[4].Visible = false;)
  • Format Datagrid Data. Full control over formatting of data as compare to previous method.
  • Replace Control before exporting to excel. eg: Removing Hyperlink, dropdownlist, checkbox and other controls before exporting data to excel.
  • Can Export All data @ once, bydefault you can only export page full of data.

Lets understand by example, consider following datagrid, which contain "Employee Name" and "Email" as Hyperlink, but while exporting data i want Hyperlink from email should be removed.




Utility Code:
It is self explanatory

protected void btnExportToExcel_Click(object sender, EventArgs e)
{
DataTable dtOriginal = new DataTable();
dtOriginal = ReturnTable(); //Return Table consisting data

//Create Tempory Table
DataTable dtTemp = new DataTable();

//Creating Header Row
dtTemp.Columns.Add("<b>Employee Name</b>");
dtTemp.Columns.Add("<b>Email</b>");
dtTemp.Columns.Add("<b>Join Date</b>");
dtTemp.Columns.Add("<b>Salary</b>");
double dSalary;
DateTime dtDate;
DataRow drAddItem;
for (int i = 0; i < dtOriginal.Rows.Count; i++)
{
drAddItem = dtTemp.NewRow();
drAddItem[0] = dtOriginal.Rows[i][0].ToString();//Name
drAddItem[1] = dtOriginal.Rows[i][1].ToString();//Email

//Join Date
dtDate = Convert.ToDateTime(dtOriginal.Rows[i][2].ToString());
drAddItem[2] = dtDate.ToShortDateString();

//Salary
dSalary = Convert.ToDouble(dtOriginal.Rows[i][3].ToString());
drAddItem[3] = dSalary.ToString("C");

dtTemp.Rows.Add(drAddItem);
}

//Temp Grid
DataGrid dg = new DataGrid();
dg.DataSource = dtTemp;
dg.DataBind();
ExportToExcel("BudgeReport.xls", dg);
dg = null;
dg.Dispose();
}

private void ExportToExcel(string strFileName, DataGrid dg)
{
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
Response.ContentType = "application/excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
dg.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}

Thursday, December 13, 2007

Best C-Sharp.Net Blog

Best C#.Net Blog as Compiled by Timm Martin of DevTopics.com.

Read Original Post

Monday, December 10, 2007

Numeric String Format in .Net

Must Know Issue: Basics of String Format in .Net


Numeric Format

double dValue = 55000.54987D;

//displaying number in different formats

Response.Write("Currency Format: " + dValue.ToString("C") + "
"
);

Response.Write("Scientific Format: " + dValue.ToString("E") + "
"
);

Response.Write("Percentage Format: " + dValue.ToString("P") + "
"
);

/* OUTPUT */

Currency Format: $55,000.55
Scientific Format: 5.500055E+004
Percentage Format: 5,500,054.99 %

Getting Culture Specific String

double dValue = 55000.54987D;

//You can Remove this line

Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");

//This line will automatically detect client culture

//and display data accordingly

//Here culture has forcefully changed to german to

//view difference in output

CultureInfo ci = Thread.CurrentThread.CurrentCulture;

//displaying number in different formats

Response.Write("Currency Format: " + dValue.ToString("C",ci) + "
"
);

Response.Write("Scientific Format: " + dValue.ToString("E",ci) + "
"
);

Response.Write("Percentage Format: " + dValue.ToString("P",ci) + "
"
);

/* OUTPUT */

Currency Format: 55.000,55 €
Scientific Format: 5,500055E+004
Percentage Format: 5.500.054,99%

Most Recent Post

Community Updates

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape