Monday, December 14, 2009

Pass Javascript value to server side object & Event

Hi Friends

Its is very tuff job to transfer any javascript object to server side (code behind) objects and event by javascript. but .NET Framework 4 make this job very easy you can now pass Javascript from Javascript to code behind file using Ajax.

Passing parameters as primitive type

The easiest and most common way to passing javascript object information to server side method is Send it as individual parameters to the sever side method, please check below code show how to call server side "AddPerson" method with 4 argument

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

var p1 = new Person('Adday', 'Michel','New York', 28);

var a = 0;

function passvalue() {

JavaWebApps.PersonService.AddPerson(p1.firstName,p1.lastName,p1.City,customer.age,function (response) {

});

}

</script>


The Person JavaScript class is a simple class with four properties firstName, lastName,City and age.


function Person(firstName, lastName,City, age) {

this.firstName = firstName;
this.lastName = lastName;
this.City=City;
this.age = age;
}


And code for server side AddPerson Method code

[WebMethod]
public string IAddPerson(string firstName, string lastName, string City, int age) {

return "Person added";
}

Thursday, October 22, 2009

Delete all tables along with Constraint

DECLARE @TableName NVARCHAR(MAX)

DECLARE @ConstraintName NVARCHAR(MAX)

DECLARE Constraints CURSOR FOR

SELECT TABLE_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE



OPEN Constraints

FETCH NEXT FROM Constraints INTO @TableName, @ConstraintName



WHILE @@FETCH_STATUS = 0

BEGIN

EXEC('ALTER TABLE [' + @TableName + '] DROP CONSTRAINT [' + @ConstraintName + ']')

FETCH NEXT FROM Constraints INTO @TableName, @ConstraintName

END



CLOSE Constraints

DEALLOCATE Constraints



DECLARE Tables CURSOR FOR

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES



OPEN Tables

FETCH NEXT FROM Tables INTO @TableName



WHILE @@FETCH_STATUS = 0

BEGIN

EXEC('DROP TABLE [' + @TableName + ']')

FETCH NEXT FROM Tables INTO @TableName

END



CLOSE Tables

DEALLOCATE Tables

Monday, August 10, 2009

આ માણસ જાણે મોબાઇલ થઈ ગયો

આ માણસ જાણે મોબાઇલ થઈ ગયો

જરૂર જેટલી જ લાગણીઓ

રિચાર્જ કરતો થઈ ગયો

ખરે ટાણે જ ઝીરો બેલેન્સ

દેખાડતો થઈ ગયો

આ માણસ જાણે મોબાઈલ થઈ ગયો!

સામે કોણ છે એ જોઈને

સંબંધ રિસિવ કરતો થઈ ગયો

સ્વાર્થનાં ચશ્મા પહેરી મિત્રતાને પણ

સ્વીચ ઓફ કરતો થઈ ગયો

આ માણસ જાણે મોબાઈલ થઈ ગયો!

આજે રીટા તો કાલે ગીતા એમ

મોડેલ બદલતો થઈ ગયો

મિસિસને છોડીને મિસને

એ કોલ કરતો થઈ ગયો

આ માણસ જાણે મોબાઈલ થઈ ગયો!

પડોશીનુ ઊંચું મોડેલ જોઈ

જુઓને જીવ બાળતો થઈ ગયો

સાલું, થોડી રાહ જોઈ હોત તો!

એવું ઘરમાં યે કહેતો થઈ ગયો

આ માણસ જાણે મોબાઈલ થઈ ગયો!

હોય બરોડામાં અને છું સુરતમાં

એમ કહેતો એ થઈ ગયો

આજે હચ તો કાલે રિલાયન્સ એમ

ફાયદો જોઈ મિત્રો પણ બદલતો થઈ ગયો

આ માણસ જાણે મોબાઈલ થઈ ગયો!

ઈનકમિંગ – આઉટ ગોઈંગ ફ્રીનાં ચક્કરમાં

કુટુંબનાં જ કવરેજ બહાર એ થઈ ગયો

હવે શું થાય બોલો

મોડેલ ફોર ટુ ઝીરો એ થઈ ગયો

આ માણસ જાણે મોબાઈલ થઈ ગયો!

Swine Flu

Hi Friends

In now days Swine flu is biggest threat spread in every human.So I decide to write this post apart from technical post on .NET framework and VS2008

The following information can be very useful. Also the attached PDF will guide you enough to understand the symptoms and the common mistakes you should avoid to further spread this deadly disease. Take some time and go through the same.

I believe a little awareness always helps. Hope this indeed will.

Cheers,


Swine Flu (H1N1)

With the first swine flu death being recorded in INDIA few days back, it is all the more important to have readily available information regarding the symptoms, prevention and the right place for treatment. This will not only minimize the chances of us contracting it but in case we know someone who has these symptoms we can guide them to the right hospital.

The attached presentation will give you additional details about the swine flu, its symptoms and prevention measures.

As a unified force we can stop the spread of this EPIDEMIC and help cure the affected ones with timely and correct treatment.

Friday, August 7, 2009

Query Hierarchical data Using CTE in T-SQL 2005

this script uses the new CTE feature of SQL Server 2005 to display the hierarchical data all at once. I have added a check to prevent infinite loop in case there is a loop in the data (actually, there is one in the example). But this script has some limitations:

1) The maximum number of childern for a parent is 2^33. But you can enlarge this number by expanding the slots in s column (currently, it's 10 characters wide for each level).

2) The maximum number of levels is 100. This is the limitation of T-SQL.


CREATE TABLE Hierarchy(
Parent VARCHAR(20) NOT NULL,
Child VARCHAR(20),
CONSTRAINT UIX_ParentChild
UNIQUE NONCLUSTERED (Parent,Child)
)
GO
CREATE CLUSTERED INDEX CIX_Parent ON Hierarchy(Parent)
GO
INSERT Hierarchy VALUES('World','Europe')
INSERT Hierarchy VALUES('World','North America')
INSERT Hierarchy VALUES('Europe','France')
INSERT Hierarchy VALUES('France','Paris')
INSERT Hierarchy VALUES('North America','United States')
INSERT Hierarchy VALUES('North America','Canada')
INSERT Hierarchy VALUES('United States','New York')
INSERT Hierarchy VALUES('United States','Washington')
INSERT Hierarchy VALUES('New York','New York City')
INSERT Hierarchy VALUES('Washington','Redmond')
--The following row will generate a loop regarding the 'World'
INSERT Hierarchy VALUES('Redmond', 'World')
GO

Declare @Root nvarchar(100);
Set @Root ='World';
With t as (
Select parent = convert(varchar(20),'--'),
Child = convert(varchar(20),@Root),
L = 0,
S = Convert(varchar(max),'')
union all
select h.*, t.L+1, t.S+ convert(varchar(max),right('0000000000'+convert(varchar, row_number() over (order by h.Parent )),10))
from hierarchy h
join t on h.parent = t.child and h.Child <> @Root
)
Select space(L)+Child, * from t order by s;

Sunday, August 2, 2009

Total solution for PDF(pdfdonkey)

Hi friend this is very small but use full tool which me and my friend wrote for PDF solutions

PDF Donkey is where you can find all solutions related to PDF Utilities.

PDF Donkey can performs following tasks for you.

PDF Splitter/Merger

PDF Encrypter/Decrypter

PDF to Image

Image to PDF

Image Extraction from PDF File.

for download this project visit this web site

http://pdfdonkey.com/products.html

Friday, July 10, 2009

Security Code Review with Microsoft's Code Analysis Tool (CAT.NET)

Microsoft recently released a new build of CAT.NET, the Code Analysis Tool from the Microsoft IT Information Security Tools Team (formerly known as the Connected Information Security Group). This is the same group that works on the AntiXSS Library that I wrote about in "Fighting Cross-Site Scripting with Anti-Cross Site Scripting Library 3.0." The tool is a static analysis tool that performs security reviews on the intermediate language (IL) contained in .NET project binaries. CAT.NET uses tainted data flow analysis, sometimes called tainted-variable analysis. This type of analysis attempts to identify what sources of untrusted inputs could affect trusted parts of an application.

CAT.NET couldn't be easier to use. It is implemented as a Visual Studio add-in that installs a CAT.NET Code Analysis item to the Tools menu. Select that item to open the CAT.NET window, and click the green arrow to start analysis. After several moments (depending, of course, on how large the project is), you get the results. The following image shows the results of running the tool on a single-page website that has some fairly extensive code behind it.

CAT.NET

CAT.NET identified only two potential problems—a redirection vulnerability and a single cross-site scripting possibility. But because the input value from a query string is used extensively in the code, CAT.NET found 36 locations where it could cause a problem.

In a fresh installation of CAT.NET, you get eight rules that define problems that the tool looks for. The rule definitions are transparent, consisting of easily viewed XML files in a set of folders that categorize the tools. The XML defines sources, sinks, and filters. The tool finds security vulnerabilities by tracing a data-flow path from various sources, such as user input and exceptions, to a destination in the list of sinks. It can filter the data flow, in which case the vulnerability is ignored. Each rule lists the sources, sinks, and filters defined in XML files in the \Rules directory where CAT.NET is installed. You can easily add your own rules if you take the time to figure out the proper XML structure.

In my tests, the tool didn't always identify real risks, usually because it wasn't able to get enough code context information to see any mitigations in the code. For example, it flagged my use of a query string variable under the Cross-Site Scripting rule to read data from the database, even though I explicitly and immediately converted the value to an integer before using it. Further, the user is welcome to view any and every record associated with valid integer values. This "problem" repeated throughout the code on one of my pages. Nevertheless, it was good to have that flagged, letting me take a fresh look at the code to reassure myself that it was not a real vulnerability.

CAT.NET doesn't have the prettiest interface, nor is it a particularly fast tool. It is implemented as a dockable window in Visual Studio, but it's a wide, three-paned window that doesn't really work well as anything but a floating window. And text wrapping is ugly. Performance isn't a big issue because you're not likely to use the tool on every build, just at benchmarks during development. But these are minor quibbles; not everything in life needs to be pretty or fast!

It's definitely worthwhile to check out CAT.NET and see what it finds in your code. The results won't be pretty, but if it helps you find just one vulnerability in your code, it's time well spent.

Resources:

You can download the new build of CAT.NET at these URLs:

32-bit version of CAT.NET

64-bit version of CAT.NET

The best place for information about CAT.NET is at Microsoft's Connected Information Security Group's blog. They recently changed URLs, but most of the interesting CAT.NET background posts are at the old address, so check out both:


Reference

Don Kiely

Wednesday, June 17, 2009

Delete all Procedure of Database

Sometimes you need to delete all the stored procedures in database. instead of deleting SPs one by one.
This query generates the drop statements for all the stored procedures.

First, right - click on the query pane and choose "Results to text".

Next, execute this script:

Select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%'

What you'll get is a nice list of "Drop Procedure" statements that you can paste into the query editor window and execute.

Friday, April 24, 2009

Use "App_Offline.htm" feature while updating a web site

"App_Offline.htm" feature provides a super convenient way to bring down an ASP.NET application while you updating a lot of content or making big changes to the site where you want to ensure that no users are accessing the application until all changes are done.

The way app_offline.htm works is that you place this file in the root of the application. When ASP.NET sees it, it will shut-down the app-domain for the application and instead send back the contents of the app_offline.htm file in response to all new dynamic requests for the application. When you are done updating the site, just delete the file and it will come back online.

Wednesday, January 7, 2009

Connect Mobile Emulator with Internet

Hi Friends

I am learning window mobile application development. I made one application in which i want to browse some web site.on window mobile device my application work fine but on Emulator it does not work, because whenever emulator launch it is not adopt my computer network setting ( which you can say Microsoft Development team fault ;). so I dig in to mobile emulator setting and find solution by which we can set our computer networking setting to emulator. for that Steps are
  1. First Install Microsoft ActiveSync software according to your Operating System
  2. Run Microsoft ActiveSync Software and browse File >> Connection Settings.
  3. In Connection Setting dialog box select DMA from dorp down display below Allow connection to one of the following
  4. Open Device Emulator Manager from Visual studio
  5. Right click on emulator and select connect option
  6. Once emulator running again right click on emulator and cardle the device

If you see nothing happened to your Windows Mobile Device Center, it doesn’t mean you missed some steps from the above. It happened only because the Device Emulator 1.0 is the one comes with Visual Studio 2005 has this cradle problem on Windows Vista.

The solution is to download Microsoft Device Emulator 2.0 and by installing 2.0, it will replace the old one. Read this note from its download page: “DeviceEmulator 2.0 has taken a few design changes to work with the Windows Vista operating system that enables the emulator to be cradled using the Windows Mobile Device Center”.

Thanks

Abhishek Hingu

Friday, January 2, 2009

Getting run time error message "The database file has been created earlier version of Sql Server compact."

Problem

When running samples/demos of the Sync Services intended for SQL Server CE 3.5 Beta 2 you receive the following message:
"The database file has been created by an earlier version of SQL Server Compact. Please upgrade using SqlCeEngine.Upgrade() method"
Cause

The reference in your project to the System.Data.SqlServerCe assembly is pointing to an older version of the file. This may occur if you already have Visual Studio 2005 installed on your PC.

Solution
In the Visual Studio project, ensure the file path of the System.Data.SqlServerCe reference points to the correct version – in this case SQL Server CE 3.5 Beta 2 (Desktop):
C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll

An example of an incorrect file reference for SQL Server CE 3.5 Beta 2 is as follows:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\System.Data.SqlServerCe.dll