01 December 2007

You may have seen Microsoft Download Center so many times.


But now there is a new look:



Visit Microsoft Download Center Beta!

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.

07 September 2007

Lets create Outlook 2007 Add-In using Visual Studio 2005.

If you have not installed VSTO then Download Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE) (x86).


Start IDE.

Click on File, New project

Select Outlook Add-In and Click on OK.

you will find some code like this:

Public
Class ThisAddIn
 Private WithEvents btn1 As Office.CommandBarButton

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup

End Sub


Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown

End Sub

End Class


Now add following code in StartUp event:

Dim explorer As Outlook.Explorer = Me.Application.ActiveExplorer()  

If explorer IsNot Nothing Then

Dim bar As Office.CommandBar = explorer.CommandBars.Add("saAction Bar", Temporary:=True)

bar.Visible = True

btn1 = bar.Controls.Add(Office.MsoControlType.msoControlButton, Temporary:=True)

btn1.Caption = "saAction Button"

btn1.Tag = "myOutlookAddin1.btn1"

btn1.Style = Office.MsoButtonStyle.msoButtonCaption

End If

And declare Button click event any where in the class.

 Private Sub Btn1_Click(ByVal ctrl As Office.CommandBarButton, ByRef cancelDefault As Boolean) Handles btn1.Click

MsgBox("Hi! this is VSTO")

End Sub


Done.

Now, Just run the project. Press F5, Outlook will automatically start and It will show a button there, and click on that button. See below "saAction Button" and messagebox.



Outlook is a very big application and using VSTO, you can utilize it's functions.

25 August 2007

I think that here is the fastest way to bind a data grid for web application.

  • Login with SQL Server 2005 with Windows Authentication.


  • Open your database,
  • Right Click your table and click on Modify menu for which one do you want to bind.
  • Select Fields which are do you want to show in browser. user Control key to select.

  • Press Control + C to copy those column.
  • Now Open a web page in devenv.
  • And Click to for Control + V data binding.
  • See bellow
All Selected Columns and Connection string will be automatically

  • Press F5 to run
Result in browser.
Done. Isn't it fastest?

If you did not login with "Windows Authentication" so you have to write down password to connect that sql server in Web.config file.

24 August 2007

See this example here.

I have created an interface.
public interface myInterFace1
{
void Operation(string myParam);
string myName();
}
it have two methods. Operation and myName.

Now create a class.
class Program
{

}
Now, lets inherit with interface.
    class Program:myInterFace1
{

}
Now I'm using myInterFace1 in Program class, So I need to write down all methods of that interface in my class.

it's do that with rick.

Right click on inter face name near (:) sign.
It will pop up a menu, where you found "Implement Interface" menu.

Click on that menu.

class Program:myInterFace1
{
static void Main(string[] args)
{
}

#region myInterFace1 Members

public void Operation(string myParam)
{
throw new Exception("The method or operation is not implemented.");
}

public string myName()
{
throw new Exception("The method or operation is not implemented.");
}

#endregion
}
All method of that interface will be write down there in that class automatically.

It's a very small but useful example during the development of code.

15 August 2007

Here you will found programing code difference between VB.NET and C#.

Following code structures are available there with examples.
  • Program Structure
  • Comments lines
  • Data types
  • Constants
  • Enumerations
  • Operators
  • Choices (If)
  • Types of Loop
  • Array
  • Function
  • Working with String
  • Exception Handling
  • Namespaces
  • Classes and Interfaces
  • Constructors and Destructors
  • Using Objects
  • Structs
  • Properties
  • Delegates and Events
  • Console I/O
  • File I/O.

28 July 2007

Hi, Live Search, Google, Yahoo can also works like a calculator!!!


Lets try here...


Live Search result




Yahoo Search result





Some test for Google Search result







Defy All Challenges is Microsoft site, to get graphical representation using flash technology.


Get information about Office 2007, Vista, Web development and Visual Studio Team System.

Also have some fun there, creating your own cartoon animation.


click here for HTML version.

27 July 2007

Still, Just to days a go I have complete to download Visual Studio 2008 Beta 1, and do day I found that Visual Studio 2008 Beta 2 is released,

So, once again, I have started to download this new version.

26 July 2007

Finally after two weeks hard download, I have "Orcas".

Download Visual Studio Code Name “Orcas” Beta 1

Here are some screen shots:

Select .Net Framework version direct form New project dialogbox.


Create C# and Visual Basic WPF Application


Office 2007 Workbook, document direct in Visual Studio as wall as Template and Add-In.


Office 2003 Workbook, document direct in Visual Studio as wall as Template and Add-In.


Worlflow Application

There are many feature in this version which was available in Team edition of Visual Studio 2005, now they are including in this version of "Orcas".

So, I have started to learn Visual Studio 2008, What about U?

25 July 2007

We can start to give attachment with out blog.

box.net is a site where we can store our documents in a box and can be access them from anywhere.


easy to upload Images, Word document, PDF Files etc.

here is there result in a blog. There is also change view icon in top right corner.

This box is use uses Flash Player for the result.

18 July 2007

Meebo is a great online chat application where AIM, Yahoo, Google and MSN Chat is possible in one browser only.

Please Give me the solution,

Today I had a requirement that I have to get missing number form table and start new ID form that missing value...

Ex. I have a customer table.

ID Name
1 Vijay
2 Rajesh
3 Nitin
5 Manish
6 Bipin
8 Jalpesh

Here, 4 and 7 number are missing, some one have deleted that record. and now suppose user click on add new button he want to generate that missing number.

Here a I have create a small cursor to get that value:


DECLARE @lastID int,
@crrID int

SET @crrID=1;

DECLARE curJob CURSOR FORWARD_ONLY READ_ONLY LOCAL
FOR
SELECT ID FROM Customer ORDER BY ID

OPEN curJob

FETCH NEXT FROM curJob INTO @lastID

WHILE @@FETCH_STATUS = 0 AND @crrID=@lastID
BEGIN
SET @crrID=@crrID+1
FETCH NEXT FROM curJob INTO @lastID
END

CLOSE curJob
DEALLOCATE curJob

SELECT @crrID;


Done. This SQL satisfied my requirement.

But Its now a good idea where thousands of records in a table, I think that there should be some in built functions of SQL Server 2005, who can get me those missing values without any coding and quickly also.

Do you know any other solution?

16 July 2007

You can change executable or DLL files using IDE, not a completely but most improbably.

You can make change in
  • Design of almost executable file
  • Icons of the application
  • Menu name
  • Button caption

Here I m trying to change in calculator...

Regular calculator.

Go to System32 folder select Calculator.exe file, Drag this icon in IDE, of open file form File menu of IDE.


See Here, Calc.exe in Visual Studio 2005

Open calculator design and make some change.


Now, Save that file As EXE, remember that click on "Save Calc.exe As..." menu.


Save file and open that file directly using double click.

New calculator is ready to work.

You can be a one kind of hacker, but I m trying here to show just knowledge.

13 July 2007

I thick Google, Yahoo etc. mail server does not allow more then 10MB.

But here "Mail Big File" allows 100MB of attachment free.

easy three steps.
It's very easy to work XML data file with DataSet.
It's just 2 line of code to Read or Write.
Here I have a XML file...

<?xml version="1.0" standalone="yes"?>

<App xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<value>Some Value1</value>

<value>Some Value2</value>

<value>Some Value3</value>

</App>


Here I'm using Visual Studio 2005 and C# language.

now right down this code in some form load event or in button click event.

//variable and dataset name
System.Data.DataSet ds = new System.Data.DataSet("myDataSet");

//file path to read xml
ds.ReadXml(Application.StartupPath + "\\myfile.xml");

//done. Start to read file.
MessageBox.Show(ds.Tables[0].Rows[0][0].ToString());
//here you will show "Some Value1" from xml file.


//Start to write file.
//change some value.
ds.Tables[0].Rows[0][0]="new value.";

//write file.
ds.WriteXml(Application.StartupPath + "\\myfile.xml");


Done.

06 July 2007

With Visual Studio 2005 and Microsoft Office 2007 or 2003, I have created my own formula.



Open Visual Studio -> New -> Project.
Select "Class Library"

Your project name will show in Excel's Formula dialogbox.

Now you have a "Class1.vb" in your Solution Explorer.

Now right down this code in your Class file....

'imports required name space
Imports System.Runtime.InteropServices
Imports Microsoft.Win32


<ClassInterface(ClassInterfaceType.AutoDual), ComVisible(True)< _
Public Class Class1

'this is for automatically register the function in excel.
<ComUnregisterFunctionAttribute()> _
Public Shared Sub RegisterFunction(ByVal type As Type)
Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type))
End Sub

'this is for to unregister the function from excel.
<ComUnregisterFunctionAttribute()> _
Public Shared Sub UnregisterFunction(ByVal type As Type)
Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type), False)
End Sub

Private Shared Function GetSubKeyName(ByVal type As Type) As String
Dim s1 As String
s1 = "CLSID\{" & type.GUID.ToString().ToUpper() & "}\Programmable"
Return s1.ToString()
End Function


'this is Excel custom formula "
myTestFormula"
Public Function myTestFormula(ByVal anyNumber As Double) As Double
Dim result As Double = anyNumber * 2
Return result
End Function

End Class

------------------
ok, open project properties form Project menu.

click on "Compile" Tab. and check a "Register for COM imterop" option.

now save all file of the project. and build solution pressing F6.

Ok, user defined function has been created. now we have to give reference to Excel for this formula.

  • Open Microsoft Excel 2007
  • open "Excel Options" from office button icon.
  • click on "Add-Ins" tab.
  • Click on "Go" button under Manage Excel Add-ins list.
  • It will show Add-Ins dialog box.

  • Click on Automation button.
  • Under Automation Services dialogbox fine out ProjectName.ClassName.
  • here I have "myExcelFormula.myFunctions" or like that.

click on OK.
it done.

now type your formula and pass it argument and you will get the result.

here you will get the result 10 (5*2)

it's g. using this method I am creating a Bill for a form. This is a print preview of a Bill using user defined function where database is MS Access, Software is Created in VB6.0 and this formula created from Visual Studio 2005.