Search

Jan 21, 2008

Passing lists to SQL Server 2005 with XML Parameters

We frequently have requirement like

Passing IDs in comma saperated value to the sql server for further processing.

Generally what we do is just create loop and get the value from it and ...

But SQL 2005 comes up with XQuery. Using this you can easly pass such type of data also some complex thing too.

For example...

DECLARE @productIds xml
SET @productIds ='<Products><id>3</id><id>6</id><id>15</id></Products>'


SELECT ParamValues.ID.value('.','VARCHAR(20)')FROM @productIds.nodes('/Products/id') as ParamValues(ID)

Which gives us the following three rows:

3
6
15

Read more..

Nov 28, 2007

How to know page validity from java script

Hello All,

I was having one requirement which is as follows.

- Once you click on submit button, the button must be disabled
- All the validator should work properly then and only then button get disabled [obvious thing]
- And the page needs to be submitted back to server as well.

I was looking for the method where I can find the page valid property or value which allow me to do what I want.

There is a property Page_IsValid in java script which let me know the validity of page. But it will always set to false first time.

So I found the solution which help me to fulfill my requirement.

Have a look at following code

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

function btnSaveClientClick(objBtn)
{
var isPageValid = Page_ClientValidate();
if(isPageValid)
{
objBtn.disabled = true;
__doPostBack(objBtn.name,'');
}
}

</script>

This is the server side control [submit button]

<asp:Button ID="btnSave" runat="server" SkinID="button_plain" OnClientClick="javascript:return btnSaveClientClick(this);" Text="Save" OnClick="btnSave_Click" />

How it works:

- On client click of save button btnSaveClientClick() method get executed with single parameter this which is button itself.
- Page_ClientValidate() method used for checking client site validation, will return true or false.
- objBtn.disabled, will disable the button because objBtn is reference to our Save Button
- And last need to postback to server, so call __doPostBack(objBtn.name,'');

That's it!

Oct 22, 2007

Web service architecture

Hello Friends,

What is webservice? What is WSDL? How it works?? and many more....

I found all the answere, its really nice topic where you can find all the answers.

Have a look at this Web service architecture delicios.

Regular Expression problem???

Hello friends,

I found good link which has almost all required regular expresions, have a look at this Regular Expressions delicios.

Sep 20, 2007

Threading in C#

C# supports parallel execution of code through multithreading. A thread is an independent execution path, able to run simultaneously with other threads.

To know how its working, when to use thread etc. have a look at 'delicios'

Sep 12, 2007

Display images Directly from Memory

Hello Friends,

I was looking for functionality in which I just need to throw jpg file after changing it into memory.

One way is, save it to hard drive and then use it as target of some img tag. But this is not a good idea, so searched for such kind of logic where I can directly throw the image to client.

I used following code


//Load the bitmap image
System.Drawing.Bitmap objBitMapOriginal = new System.Drawing.Bitmap(strImagePath);
//Change the bitmap image
System.Drawing.Bitmap = ScaleAndModifyImage(objBitMapOriginal);
//Save it to response
Bitmap.Save(Response.OutputStream, ImageFormat.Gif);


But this has some problem as images saved in OutputStream I cant show any other literals or data on the same response.

Then I found a solution, First store the image in session and dynamically sets the src of image which at the end pointing to same page, on requesting that image src it throws the image which is in memory and after finishing work just flush the session.

Its fairly simple, have a look at the delicious. You can also find the code.

Sep 4, 2007

How to expire previous page

Hello all,

This is the normal problem we all are facing in Web application.

Problem comes when user use back button of browser and application start malfunctioning.

Just add following code in page load

Response.Buffer = true;
Response.ExpiresAbsolute = DateTime.Now.Subtract(new TimeSpan(0, 0, 2));
Response.Expires = 0;
Response.CacheControl = "no-cache";

Aug 21, 2007

Different Options for Importing Data into SQL Server

Hello all,

I was having problem in getting data from different server, a hugh data millions of records that i have to import.

I tried lots of methods but its very difficult to get it done.

I found some solution for such hugh task.

Have a look @ Different Options for Importing Data into SQL Server.

Aug 16, 2007

Forms Authentication in ASP.NET 2.0

Hello all,

I come accross good link, which explain you the forms based authentication.

Have a look at delicious Forms Authentication in ASP.NET 2.0

Jul 26, 2007

Can you call private members from a different class?

Is it possible to access private method in a class?

I think the OO funda says no|never, you cant access.

But .NET term Reflection is providing such functionality.

Whoooppssss these circumstances breaking a OO rule.

Read more: I have delicious You can call private members from a different class.