Showing posts with label Visual Studio 2008. Show all posts
Showing posts with label Visual Studio 2008. Show all posts

Wednesday, October 28, 2009

Health monitoring

Health monitoring in the Web.config file.



This is nice feature in the dotnet frame work 3.5


it will automatically write the event log, When you will not handle the exception in the application,


<system.web>
<healthMonitoring enabled="true"></healthMonitoring>
</system.web>

Monday, April 13, 2009

Showing Intelligence for JavaScript methods in different Files.


Showing Intelligence for JavaScript methods in different Files.
I have created Jscript1.js with following methods with out definition.




I am referring the jscript1.js file in to script2.js using Reference Attribute. After adding the reference am getting intelligence for the jscript1.js file methods.

Thursday, January 8, 2009

Typed Dataset Using Asp.net 3.5

Typed Dataset Using Asp.net 3.5

Before starting we will remember in Dotnet frame work 2.0. In this it will create only xsd and class file for that. But it will not create Adapters for retrieving dataset. We should use Sqldataadapter for getting the data. But in Asp.net 3.5 frame work it will create data adapter for that xsd. So we can get the typed dataset via adapter instead of getting from Sqldataadapter. See the step by step explanations with examples.


Step 1:

Create one employee database with table name called “contact” which has created for you. Open that database in server explorer of visual studio 2008. See picture A






Picture A

Step 2:

Create Contact.xsd file through add file option in project file. See picture B


Picture B

Step 3:

Drag and drop contact table in to the contact.xsd screen. After waiting few seconds it will create Contact.xsd file automatically. Now you can see in picture C


Picture C


Step 4

Writing few lines of code assigning this typed data values in gridview. See picture as well as the code to retrieve the typed dataset. Create one aspx page with gridview control. I am going to write the code in page load event for that page.

Example:

protected void Page_Load(object sender, EventArgs e)
{
ContactTableAdapters.ContactTableAdapter Dataadapt = new Dotnetspider.ContactTableAdapters.ContactTableAdapter();
grdlist.DataSource = Dataadapt.GetData();
grdlist.DataBind();
}

Note: ContactTableAdapter class will create automatically. This is the one main difference between frame work 2.0 and framework 3.5. But in 2.0 frame work will not create.

Happy Coding

By

Bala

Note:Images will update soon. Sorry for the inconvenience.

Monday, January 5, 2009

Using Filter Expressions with an SQL Data Source in ASP.NET VB 2008

In Visual Studio 2008, we can filter the dataset in c# with out using sqlquery.

If you use sqldatasource in your project. we can filter the dataset in c# coding itself.

Example1

If (Session("FiltExp") <> Nothing) Then
SqlDataSource1.FilterExpression = Session("FiltExp").ToString()
End If

Example2

SqlDataSource1.FilterExpression = "city='" & DropDownList1.SelectedValue & "'"

Example3

SqlDataSource1.FilterExpression = "BirthDate > #" + dt + "#"
Session("FiltExp") = "BirthDate > #" + dt + "#"

Hidden Features in C#

1) Using @ for variable that are keyword.

var @object = new object();
var @string = "";
var @if = IpsoFacto();

2) Aliased Generics.

using ASimpleName = Dictionary<string, Dictionary<string, List<string>>>;


Allows you to ASimpleName,instead of

Dictionary<string, Dictionary<string, List<string>>>;

Use it when you would use the same generic big long complex thing in a lot of places.

Thursday, January 1, 2009

Accessing server side event using Ajax 3.5 with Visual Studio 2008

Accessing server side event using Ajax 3.5 in visual studio 2008.

when we compare with earlier method,This may easy to write the code for developer.

step1 :

Include in your application system.web.extensions 3.5

Step 2:

In the script manager tag EnablePageMethods attribute make it true. it will help you to create method in the pagemethod class. Then only you can access the server event in the client side.


<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>

Step 3:

We should include the namespace over the server side method.[System.Web.Services.WebMethod].

Earlier we have used [Ajax.Ajaxmethod].

Example
[System.Web.Services.WebMethod]
public static string Message(string one,string two)
{
return one + two;
}

Step 4:
Client side. while calling the server side method. it will create two default methods. if it is succeed it will call OnGetMessageSuccess, and fails it will call OnGetMessageFailure.
Example

function GetCall()
{
PageMethods.Message("122","122",OnGetMessageSuccess, OnGetMessageFailure);
}
function OnGetMessageSuccess(result,userContext,methodName)
{
alert(result);
alert(userContext);
}
function OnGetMessageFailure(error,userContext,methodName)
{
alert(error.get_message());
}