25 November 2007

ASP.NET site have some new video series.

Download learnig video ASP.NET 3.5 and Visual Studio 2008. And Click here to download Linq videos.

20 November 2007

Add validation to WebUserControl, Normally when we click on ControlToVelidate property, it automatically show as all the list of WebControls of that from, But you will not find WebUserControl name there.

Solution is that just write down that WebUserControl name and type "$" sign and write down WebControl name which one is going to validate form that WebUserControl.

for example:
  • I created a webusercontrol and there is a textbox in that control.
  • I will drag that webusercontrol in my aspx page.
  • It's default name will be "WebUserControl1"
  • Now I will put a RequiredFieldValidator in my aspx page.
  • Then I will write down in ControlToVelidate = "WebUserControl1$TextBox1"
Because "WebUserControl1" is my web control name in my aspx page. and "TextBox1" this the name of that control in that Web User Control.

This is very ease and useful method to validate WebUserControl.

18 November 2007

28 September 2007

FireFox has a grate Add-In which allows to save any web page to JPEG or PNG format.

It's Save As Image.

Click here to Download.

Save whole web page or you can also crop any part of that web site.

It's very useful.

27 September 2007

www.homepagestartup.com provides a very useful service that you can have multiple home page in a single browser.


It is automatically stores sites information in cookies and when you come back in this site again it will display the same, There is also Tab feature to manage more sites.

Just click on icon, add URL and save it.

You should have to register to get more features.

24 September 2007

One day when I was debugging the code. It started to show hexadecimal values automatically.

I don't know that how it was stared. and I also did not know that how to see decimal back at that time.

but it was simple option that was in Local Window that named "Hexadecimal Display".

Click on Debug Menu -> Windows -> Local.

Right Click on Local Window and get this option as pop-up menu.

19 September 2007

Create shapes on form as Visual Basic 6.0 can do that directly on the form.

Power Pack 2.0 is a line, shape controls, printform component, and printer compatibility library.

It has 4 controls.

There are so many property and event.

Download Microsoft Visual Basic 2005 Power Packs 2.0

17 September 2007

See MSDN Magazine in a book format.

Click Here.


Have fun with moving page...


There is also another magazine for "Dr. Dobb's Journal".

15 September 2007

I have created a user control "Any Drop Down List" anyDDL. Its use to show drop download list form database very quickly.

Lets create that user control.

I'm using Visual Studio 2005, Framework 2.0, SQL Server 2005, ASP.net, C# language to build it.

Start Visual Studio,
Click on Create New Web Site.
Select ASP.net web site.
Click on OK button.

Now,

click on Web Site menu or right click on project name in Solution Explorer.
Select menu named "Add New Item".
It will show a add item dialog box as bellow.


Select Web User Control there and right down its name anyDDL, click on OK button.

Now add a Drop Down List form toolbox.



Rename that drop down list with "thisDDL".

now add some following code in code behind file.



using System;
using
System.Data;
using System.Data.SqlClient;

/// This Drop down list can handle all kind of Values automaticaly.
///saCode 14Sep2007


public
partialclass userControls_anyDDL : System.Web.UI.UserControl
{
#region
private variables
private string _SQL;
private string _WhereSQL="";
private String _allowSelectionByUserValue;
#endregion

#region
Public Propertys
///SQL Stored Procedure Name Comes here.

public string SQLstring
{
get { return _SQL; }
set { _SQL =value; }
}

/// SQL where Condition
public string WhereValue
{
get { return _WhereSQL; }
set { _WhereSQL =value; }
}

/// Selected Value of Drop Down List Box
public string SelectedValue
{
get{ return ddlThis.SelectedValue;}
set{ddlThis.SelectedValue = value;}
}

/// Somthing like "---Other---" or "--Select--"
public string allowSelectionByUserValue
{
get { return _allowSelectionByUserValue; }
set { _allowSelectionByUserValue = value; }
}

#endregion

public void ReBindData()
{
BindWithData();
}

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

private void BindWithData()
{
if (SQLstring !=null)
{
string _strConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

SqlConnection _objCon = new SqlConnection(_strConnectionString);
SqlCommand _objCmd = new SqlCommand();
System.Data.
DataSet _objDataSet = new System.Data.DataSet();

_objCmd.Connection = _objCon;
_objCmd.CommandType = System.Data.
CommandType.StoredProcedure;
_objCmd.CommandText =
"uspAnyDll";

SqlParameter _paramSelectType = new SqlParameter("@selectType", System.Data.SqlDbType.VarChar);
SqlParameter
_paramWhereValue = new SqlParameter("@WhereValue", System.Data.SqlDbType.VarChar);

_paramSelectType.Value = _SQL;
_paramWhereValue.Value = _WhereSQL;

_objCmd.Parameters.Add(_paramSelectType);
_objCmd.Parameters.Add(_paramWhereValue);

SqlDataAdapter _objAdapter = new SqlDataAdapter(_objCmd);
_objAdapter.Fill(_objDataSet);

ddlThis.DataSource = _objDataSet;
ddlThis.DataTextField =
"Value";
ddlThis.DataValueField =
"ID";

ddlThis.DataBind();

if (allowSelectionByUserValue != null)
{
System.Web.UI.WebControls.
ListItem
_listItem =
new System.Web.UI.WebControls.ListItem(allowSelectionByUserValue, "0");
_listItem.Selected =
true;

ddlThis.Items.Add(_listItem);
}
if (this.SelectedValue != null)
{
ddlThis.SelectedValue =
this.SelectedValue;
}
}
else
{
//Throw Expression
}

}

}



Now we have to create stored procedure named "uspAnyDll" to get data form SQL Server.




-- =============================================
-- Author: <sa>
-- Create date: <15Sep2007>
-- Description: <saCode>
-- =============================================

CREATE PROCEDURE uspAnyDll
--ALTER PROCEDURE uspAnyDll
@selectType varChar(50),
@WhereValue varChar(50)
AS
BEGIN

SET
NOCOUNT ON;

BEGIN
TRY

--you can change this name and SQL as you database requirement.
--but don't change Field name , ID and Value both are static typed in that user control.

IF @selectType='GroupData'
SELECT GroupID AS [ID], Name AS [Value] FROM tblGroupWHERE RecordStatusID=1

IF @selectType='User Information'
SELECT UserID AS [ID], UserName AS [Value] FROM tblUser WHERE CompanyID=Convert(int, @WhereValue)

IF
@selectType='State'
SELECT StateID AS [ID], StateName AS [Value] FROM tblState

END
TRY
BEGIN CATCH
SELECT
'Error! : ' + @@ERROR
END CATCH

END


you can write down you own query here but don't change it's title "ID" and "Value", because those are static in user control code.

Thats all.
User Control is ready to run. open default.aspx page and drag this control from Solution Explorer.

It will display a drop down list control. See it property panel.


Here is the description for each property:

allowSelectionByUserValue : Some selection message. like "---Select---"
SelectedValue : any selected value if required.
SQLstring : SQL Server stored procedure parameter comes here.
WhereValue : any where condition to pass in that stored procedure.


See, here I have create three different select query in uspAnyDll.

I drag three times anyDDL, and pass SQLstring property as "GroupData', 'User Information' and 'State'. this are actually sql stored porcedure parameters.

and just press F5.

See the result.



Now, using this user control, you can get quickly bind data.

08 September 2007

Start to use isError formula in excel when you are calculating something.

I have seen many time error, In Excel.
  • #Ref
  • #DIV/0
  • #NAME?
You can remove all this error and also vice some user friendly value or message there by using ISERROR formula.

IsError(value) returns boolean value in True or False.

try some example in your excel sheet.

=IsError(1/0)

it will return TRUE, it mean there is some error.

Here in this case you can also vice some error message using if condition.

=IF(ISERROR(1/0), "Some Error!", 1/0)

or like that.

Ok, if you don't want to write down this formula every where in your calculation and you will see #NAME?, #Ref, #DIV/0 etc. messages in your excel screen, at list you should not print out them.

You can also hide those error when did you print.

Click on Page Setup.
Click on Sheet Tab.
there is a list box named "Cell error as".
See following image.


But, IsError formula is best, this formula is form Office XP version.