Wednesday, April 20, 2011

OO design principles

Forcefully download the pdf files

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition""attachment; filename=axz.pdf");
string path = "xyz.pdf";
byte[] buffer = System.IO.File.ReadAllBytes(path);
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.Flush();

Monday, April 11, 2011

Tuesday, March 29, 2011

Left outer join in Linq C#


Left join Linq

from a in aa
join a in xx on a.d equals x.y into DefaultOrEmptyXDetails
from a in DefaultOrEmptyXDetails.DefaultIfEmpty()
select new a)

Wednesday, March 23, 2011

Updating multiple rows from trigger byy inserted table

Hi All
Many times we are facing that we need to change the value of Column1 of Table2 when Table1 updates.

This below is given solution by- Nipam Budhabhatti
So we need trigger.
We can either select value in some variable.
but it has problem that we cannt update all rows.
so this is the solution
by implementing it we are sure that all records in Table2 are updated after updating table1.

CREATE TRIGGER [TrgName] ON Table1
FOR UPDATE
AS
UPDATE Table2
SET
Column1 = INSERTED.Column2
FROM INSERTED
WHERE
Column3 = Column4


Nipam Budhabhatti

Nipam Budhabhatti

Friday, March 11, 2011

textbox default button

javascript:



function clickButton(e, buttonid){

var evt = e ? e : window.event;

var bt = document.getElementById(buttonid);

if (bt){

if (evt.keyCode == 13){

bt.click();

return false;

}

}

}



TextBox1.Attributes.Add("onkeypress", "return clickButton(event,'" + Button1.ClientID + "')");

Thursday, March 10, 2011

go back javascript

protected void Page_Load(object sender, EventArgs e)
{
Button2.Attributes.Add("onClick", "javascript:history.back(); return false;");
}