ASP.Net comes in with a set of validation controls that automatically validate the data entered by a user. Though this validation controls are very powerful and easy to use, they have a small draw back in the sense that they require the entire page to be valid before it's submitted back to the server. There is no direct way to validate only a particular section of the page. This article will explain some circumstances where validating a particular section of page will be required and how to accomplish it.

Why validating a particular section of page is needed?

While validation controls is a great tool for validating user input before data is being submitted there are some situations where we might either want the data to be submitted without validation or we want to validate only particular fields in the form.

A typical example for when we may want the data to be passed through without validation is when a page has both submit and cancels server buttons. When the user clicks the submit button the data has to be validated whereas when the user clicks the cancel post back has to happen without any validation.

An example for when we may want to validate only particular fields of a page is a form which is divided into multiple sections with a submit button in each section. When a submit button for a particular section is clicked validation for other sections should not happen.

Solution

The solution for by passing validation on server button click is fairly easy. All we have to do is set the CausesValidation property of the button control to false. Once the CausesValidation property is set to false no validation will happen both on the client side and server side.

The syntax for doing it in the design time is

<asp:button id="cmdCancel" runat="server" Text="Cancel" CausesValidation="False"></asp:button>

This can also be done in runtime using the following code

cmdCancel.CausesValidation = false;

The solution for validating only particular fields requires few lines of JavaScript code and understanding of the Client side API provided by the validation controls. Following table lists the functions and variables provided by the client side API

Name Description
Page_IsValid A Boolean variable which indicates whether the page is valid.
Page_Validators Array of all of the validators in the current page.
Page_ValidationActive A Boolean variable which indicates whether validation should be performed. Setting this variable to False will to turn off validation.
Isvalid This is a property of the client validator indicating whether it is valid.
ValidatorEnable(val, enable) Enables or disables the client validator passed as argument.


To disable a particular validation control we can use the ValidatorEnable function as shown in the script below

<script language="javascript">
ValidatorEnable(nameofvlaidationcontrol, false)
</script>

To disable all the validation control we need to loop through Page_Validators array and disable each validator as shown in script below

<script language="javascript">
for(i=0;i< Page_Validators.length;i++)
{

ValidatorEnable(Page_Validators[i], false)
}
</script>

In order to enable validation only for particular set of controls when a submit button is clicked we need to combine the above two scripts and call it from the client click event of the button as shown in sample below

<script language="javascript">
function enableRegionValidators()
{
for(i=0;i< Page_Validators.length;i++)
{

ValidatorEnable(Page_Validators[i], false)
}
ValidatorEnable(rvRegion, true)
}
</script>

Attaching the function to the client click event of a submit button

cmdRegion.Attributes.Add("onclick","enableRegionValidators();");

When the cmdRegion submit button is clicked all the other validators will be disabled and only the validator named rvRegion will be enabled. If the validation of rvRegion is successful then the page will be submitted. The code we have used so far will disable the validatiors only on the client side, so the validation will still happen on the server side and error messages will be shown. To disable particular validators on the server side the following code has to be added to the button click event

validationcontrolname.IsValid=true;

 
Categories: Asp.Net/Web Services

Scott Guthrie has blogged a list of upcoming releases from the asp.net team for April.  He promises to do a monthly “coming soon” update.  Updates include a release candidate for the vs 2005 web application project that was dropped fum visual studio 2005 and the Atlas Control Pack extending the atlas framework.  You can read more on is blog.


 
Categories: Asp.Net/Web Services

Ted Neward has written and article for MSDN that discusses the mimatch between object programming and relational data and how different technologies go about solving this issue. The article compares how LINQ addressed the problem in relation to other technologies including JDBC/ADO.NET, code generators, SQLJ, and ORM tools such as NHibernate.


Read More


 
Categories: Asp.Net/Web Services

9Rays has released a new TreeView product for ASP.NET. FlyTreeView is a dynamic treeview control with native ASP.NET control, features visual designers, and native .NET DataBinding to any ADO.NET source (DataSet, DataReader, arrays, and IList implementations, etc.).

In addition, the new product offers drag-and-drop operations, full ASP.NET viewstate support, highly customizable styles and behaviors, XML node sources to enable load on demand, FlyNodeSet control to provide on demand nodes renderring and loading (ex. file system), checkboxes, multiple postback events (select, deselect, expand, collapse, check, uncheck), server side handling of all client events, comprehensive client object model, context menu, and flexible licensing options.

Founded in 1998, 9Rays.Net brings together together several groups of expert developers. Each group offers its own unique product line. These highly-skilled professionals have joined their efforts to achieve better marketing results and to provide the best quality of their products.

9Rays.Net has gained wide experience on the tools and components market, developing high-quality products for the following platforms: Microsoft. NET (Windows.Forms and ASP.Net), Borland Delphi, C++ Builder, and ActiveX. The company's primary product focus is on development of .Net tools and components compatible with Visual Studio .Net, C# Builder, Delphi.Net and other IDEs for .Net Framework.

For further information please visit: www.9rays.net.

 
Categories: Asp.Net/Web Services

August 10, 2005
@ 11:10 AM

Making the appropriate selection of an ASP to ASP.NET migration strategy is not always clear cut. As a developer, you would probably be tempted to rewrite the entire web application in Microsoft .NET from scratch. However, your manager might not be as enthusiastic as you are to this idea. The application is already in production and satisfies the requirements. Why follow a more risky and costly path if it is possible to start extending the application in .NET and at the same time preserving an investment in the legacy ASP code? Especially if a complete migration can be achieved gradually in a number of evolutionary migration steps, with every step resolving a concrete migration-justifiable problem.


Read More


 
Categories: Asp.Net/Web Services

he Microsoft® Dynamic Systems Initiative (DSI) provides a roadmap for simplifying enterprise software development, deployment, and management. Current Microsoft products and technologies that support the DSI model for system management include Automated Deployment Services, Microsoft Operations Manager (MOM) 2005, Systems Management Server (SMS) 2003, Virtual Server 2005, and Windows Server Update Services. Future technologies expected to extend the DSI model include Visual Studio® 2005 Team System and the System Definition Model (SDM) planned for a future version of Windows Server. (For more information about DSI, see Dynamic Systems Initiative.)

With these key DSI and SDM deliverables planned for the future, developers need manageable apps right now. Fortunately, the current version of Windows® Management Instrumentation (WMI) is able to satisfy many manageability requirements. In this article I'll demonstrate how WMI provides a first step towards DSI-style system management. I will develop a WMI-aware monitoring solution you can use to instrument your ASP.NET applications, and I'll introduce you to the capabilities of MOM 2005 that allow you to then monitor these instrumented applications.


Read More


 
Categories: Asp.Net/Web Services

Start Time: Friday, August 05, 2005 9:00 AM (GMT-08:00) Pacific Time (US & Canada)
End Time: Friday, August 05, 2005 10:00 AM (GMT-08:00) Pacific Time (US & Canada)


This webcast looks at some of the advanced features of  Visual Studio Tools for Office – VSTO, such as the new data cache available in documents, the ability to add controls at runtime, and the options available for deploying your VSTO solutions.  


 


Presenter: Ron Cundiff, Developer Community Champion, Microsoft Corporation

Ron Cundiff is the developer community champion supporting the Mid-America district and he has worked within the information technology industry for nearly ten years. Before joining Microsoft in December 2002, he worked for an independent software vendor and was responsible for the design and implementation of a global, online, commodities exchange system. He lives with his wife, Lisa, in Memphis, TN, and has two children, Kayla and Ryan


 
Categories: Asp.Net/Web Services

July 18, 2005
@ 02:55 PM

Microsoft's Anders Hejlsberg, father of the C# programming language, addresses a number of programming issues in an interview at Microsoft Watch. He discusses such issues as the implications of the increasingly tight integration of tools and languages, and "the big impedance mismatch... between programming languages... and the database world."

Anders Hejlsberg is one of Microsoft's handful of distinguished engineers. He is known for having developed the Borland Turbo Pascal compiler and for having been chief architect of Borland's Delphi technology. Hejlsberg left Borland, where he last served as chief engineer, to join Microsoft in 1996. Since joining Microsoft, Hejlsberg's greatest claim to fame has been fathering the C# programming language. Originally code-named "Cool," C# was designed to be Microsoft's Java killer.

Hejlsberg chatted in June with Microsoft Watch editor Mary Jo Foley and eWEEK.com senior editor Darryl K. Taft at the recent Microsoft Tech Ed conference in Orlando about the past, present and future of the C# programming language -- among other programming-language-related topics.

Read More | Microsoft-Watch.Com


 
Categories: Asp.Net/Web Services

July 16, 2005
@ 09:42 PM

Indigo Beta 2 will support the use of HTTP operations such as POST, PUT, and DELETE for interacting with services. The use of HTTP operations instead of more formal XML based abstractions is a fundamental principle of REST (Representational State Transfer).

From Wikipedia:
While REST originally referred to a collection of architectural principles (described below), people now often use the term in a looser sense to describe any simple web-based interface that uses XML and HTTP without the extra abstractions of MEP-based approaches like the web services SOAP protocol. Strictly speaking, it is possible (though not common) to design web service systems in accordance with Fielding's REST architectual style, and it is possible to design simple XML+HTTP interfaces in accordance with the RPC style, so these two different uses of REST cause some confusion in technical discussions.
The support for REST also requires the ability to send and recieve XML that is not based on SOAP, which is a current default limitation in Indigo but can apparently be turned off.

Via The ServerSide.Net

 


 
Categories: Asp.Net/Web Services

The Patterns & Practices team has been hard at working creating a new UI based application block, this one geared specifically toward providing flexible smart client (WinForms) interfaces using Visual Studio 2005 Beta 2. The CAB uses the concepts of SmartParts, WorkItems, Controllers, and Views, to create an extensible MVC architecture.

The Composite UI Application Block is a framework for creating user interfaces for Smart Client or Windows Forms applications. Based on an MVC architecture pattern, the CAB allows developers to create UI components as separate, discrete units (SmartParts, similar in concept to WebParts in SharePoint) that can then be orchestrated via the concept of a WorkItem.

In addition to the framework for dynamically working with SmartParts, the CAB also provides access to services needed by an application. These service can involve data access, web service calls or any other custom business logic. Also provided is a very useful State mechanism by which properties can have their data stored and retrieved automatically from the CAB state mechanisms.

To download the Composite UI Application Block, visit the Patterns & Practices Community Site.

[Via The Server Side]


 
Categories: Asp.Net/Web Services

This article is the second article in the series of introductory articles that I am writing about Mono, the "open source development platform based on the .NET framework". In this article we'll take a look at how to get going with ASP.NET on the Mono platform. Although ASP.NET is not part of the ECMA and ISO standards mentioned in the first article[^], it is still one of the major selling points of the .NET platform and provides an extremely flexible and powerful platform for developing web applications and Web Services upon. Although you can develop ASP.NET applications for Mono on a number of different operating systems this article will focus mainly on Linux, although, in saying that, I do look briefly at getting XSP running on Windows. The reason I will concentrate on ASP.NET on Linux is because those people interested in ASP.NET on Windows have an extremely powerful option at their fingertips in the form IIS and I would whole heartedly recommend using it for ASP.NET on Windows.

Where does ASP.NET stand with Mono??


The latest stable version of Mono, version 1.0.5, has a fully functional implementation of ASP.NET. This includes full support for ASP.NET Web Forms and Web Services. This essentially means that more or less any ASP.NET application that you have developed using with the .NET Framework will work with Mono. Obviously there might be changes needed, such as data access changes, removal of any reliance on .NET Framework BCL types that are not implemented in Mono yet, and also the removal of any code that makes use of platform invoke and so on. At this stage the ASP.NET support in Mono can be considered as excellent and a lot of publicly available web applications already make use of Mono's ASP.NET support. According to the Mono site the Mono Web Services stack is being used in the source control application Vault[^] by SourceGear and aspects of Mono's ASP.NET implementation are also used in the Virtuoso[^] product from OpenLink.


What are XSP and mod_mono?


There isn't much point in developing web applications and Web Services if you have no way of serving them, is there? Traditionally you would use IIS to host ASP.NET applications on Windows, although there are some other free ASP.NET web servers available such as Cassini[^]. However, when using ASP.NET with Mono you have two main options as regards which web server to host your ASP.NET applications in:



  • XSP
  • Apache

In this article we look at using both XSP (on Windows and Linux) and Apache to host your ASP.NET web applications and Web Services.


XSP


XSP is a "light-weight web server" capable of hosting and serving ASP.NET applications. It is written using C#, making extensive use of the classes in the System.Web namespace, and the source for XSP is available for download from the Mono download page[^] . It is also interesting to note that the XSP web server runs on both the Mono runtime and also on the .NET runtime which means that if you are looking for a light-weight ASP.NET web server for Windows but you don't want to use or you don't care about Mono, you could still make use of XSP. The Let's get XSP up and running section runs through how to install and use XSP on Windows and Linux.


Apache


Apache is probably the de facto standard web server used on Linux. Apache makes extensive use of modules to enable it to host and serve web applications developed in a multitude of different web programming languages and scripts. Those of you familiar with IIS but not so familiar with Apache can think of these modules as the equivalent of ISAPI extensions. So, by this stage I assume you can guess how Apache can host and serve ASP.NET application? Yep, using an Apache module. This module, called mod_mono, allows Apache to serve ASP.NET pages "by proxying the requests to a slightly modified version of XSP called mod-mono-server". mod-mono-server is installed when you install XSP. At the time of writing the current version of the mod_mono module for Apache only works for Apache on Linux and not for Apache on Windows. For this reason, when we look at ASP.NET on Apache in the Apache with mod_mono section we only look at it in the context of Linux. If you do wish to serve ASP.NET content from Apache on Windows have a look at this article[^] on CP, which shows how to use configure Apache to use Cassini to serve ASP.NET content or have a look at the Apache HTTP CLI[^] project.


What you need to know


This article assumes that you have Mono installed and working on your desired platform. The first article in this series, Introduction to Mono - Your first Mono app[^], explains how to get Mono up and running on Windows and Linux so if you have not yet done so have a look over that article. I also assume that you are familiar with ASP.NET and the semantics of ASP.NET programming as this article primarily looks at getting ASP.NET working with XSP and Apache, not at ASP.NET programming.


Lets get XSP up and running


In this section we will look at getting XSP up and running on both Windows and on Linux. Installing and running on Windows is "tackled" first simply because I want to get it out of the way and because chances are that you already have XSP on Windows considering the fact that you should have Mono already installed. Then it's on to Linux and getting XSP up and running there. To be honest, if you already have Mono running on Linux, which you should as it's one of the prerequisites for this article, then it should be relatively easy.


XSP on Windows

The first article[^] in this series ran through installing Mono on Windows. It mentioned that during the install process the installer gives you the option to select which components to install. By default, XSP is installed along with Mono but if you decided to not install XSP during the install then the easiest way to get XSP installed is to uninstall Mono and then reinstall it again. Here are the steps explaining how to install Mono and XSP on a Windows 2000 or above machine:

  1. Download the Mono Windows Installer from the Mono download page. The file I am working off is http://www.go-mono.com/archive/1.0.5/windows/mono-1.0.5-gtksharp-1.0.5-win32-0.1.exe
  2. The installer is a standard Windows installer so you can simply run it once it is downloaded by doubling clicking on it.
  3. Once the installer begins, click on next to go to the License Agreement page.
  4. You'll probably notice on the License Agreement page that there are a number of different Licenses that apply to the different components of the install. While I understand that most people simply agree and click on next, it would be irresponsible of me if I didn't recommend that you read the License Agreement before agreeing to it.
  5. Once you pass the License Agreement section you are presented with some general information about the install.
  6. Click on Next and select the install location.
  7. Click on Next again to bring you to the Select Components page. You are free to customize your installation but make sure that you install XSP. As I will be using all the components of this install in other articles in this series I would suggest that you accept the default "Full installation".
  8. Click on Next again and you can customize the name of Mono folder that appears in the Start Menu.
  9. The installer will now ask you which port you want the XSP web server to listen on. Generally this will be port 8088 but you can change it to any free port on your system. When you are ready click on Next.
  10. Finally, click on Install to install and configure Mono and XSP on your Windows machine.

Those of you who read the first article will notice that I more or less ripped the instructions from that one... I'm not lazy, just no point in rewriting what has already been said! The next step in using XSP on Windows is to run it. The Running XSP section explains how to run the XSP web server and looks at some of the command line options that you can use to alter it's default behaviour.


XSP on Linux


As with installing Mono on Linux, which we examined in the previous article, things are slightly more complicated on Linux then on Windows. However, as I already mentioned, if you have Mono installed, then getting XSP installed is going to be a breeze for you. I'm installing XSP on the same systems that I used for installing Mono in the previous article. A quick recap of what exactly I used is in order so: I used Microsoft Virtual PC 2004 and created two identical virtual PCs. I then installed SuSE 9.2 Professional with ACPI disabled and I used the default package selection when installing. In the last article I went through how to install Mono using the pre-built packages from the Mono site and also I ran through how to install Mono from source. So for the purposes of this article I will be installing XSP on a SuSE 9.2 Professional with the default package selection with Mono 1.0.5 installed along with any additional packages or programs that were installed during the Mono install.


In this article we will again look at installing from both the pre-build packages and from the source.


XSP using pre-built packages


As I am sure you can remember from the first article (if you read it that is), installing using the pre-built packages from the Mono site is one of the easiest ways of getting Mono up and running. The same thing applies to getting XSP up and running. So, head on over to the Mono download page (http://www.mono-project.com/downloads/index.html[^]) and see if there are pre-built packages for your particular Linux distribution or if there are packages for a distribution that you know will be compatible with your distribution. If there isn't a package that will work with your distribution just jump ahead to the XSP from source section where I will run through installing XSP from the source which is a simple process.


Lets get going:



  1. On the Mono download page, click on the "Packages" link beside the Linux distribution that you believe to be compatible with your distribution. I simply selected the link beside SuSE 9.2
  2. This should bring you to a page which lists a lot of different packages that have been compiled and packaged for that particular Linux distribution.
  3. Before we install XSP we need to install two other pre-built packages. These packages include files that XSP is dependent upon.
  4. The first package we need to install is the "Database Core" package that can be found in the database section. The exact name of the package will vary depending on the packages link that you selected initially but in general the name will start with "mono-data". The package I downloaded for SuSE 9.2 was http://www.go-mono.com/archive/1.0.5/suse-92-i586/mono-data-1.0.5-1.ximian.10.4.i586.rpm.
  5. Once you have downloaded this file, open it and it will launch the package manager for your distribution. At this stage simply follow the instructions to install the package.
  6. After you have installed the "mono-data" package you now need to download the "mono-web" package which will be listed under the "Web Applications, Web Services" section. The package I downloaded for SuSE 9.2 was http://www.go-mono.com/archive/1.0.5/suse-92-i586/mono-web-1.0.5-1.ximian.10.4.i586.rpm.
  7. Next, as with the "mono-data" package, simply open the package and follow the instructions to install it using the package manager of your distribution.
  8. Finally we are ready to install XSP itself. So just head back to the "Web Applications, Web Services" section of the package download page and download the "xsp" package. The package I got was http://www.go-mono.com/archive/1.0.5/suse-92-i586/xsp-1.0.5-1.ximian.10.1.i586.rpm.
  9. As with the two previous packages, simply open it and follow the instructions of your package manager to install XSP.
  10. All going well, you should have XSP installed now!

At this stage XSP should be installed on your system so you can jump ahead to the Running XSP section which gives an overview of how to use XSP. If you are having difficulty installing XSP from the packages have a look at the next section, "XSP from source", which might be able to help you out.


XSP from source


Installing XSP from the source should be breeze if you have installed Mono from source by following the instructions in the previous article[^]. Let's jump straight in:



  1. The first thing you need to do is download the source. Once again, head on over to the Mono download page at http://www.mono-project.com/downloads/index.html[^].
  2. In the source code section click on and download the "XSP web server". I downloaded http://www.go-mono.com/archive/1.0.5/xsp-1.0.5.tar.gz.
  3. Once the file has been downloaded, go to a console for the remainder of the process
  4. You can decompress the downloaded file using the command tar -xvzf xsp-1.0.5.tar.gz where xsp-1.0.5.tar.gz is the name of the file you downloaded.
  5. Next, switch to the directory where the source code has been decompressed to by typing cd xsp-1.0.5 or cd followed by the name of the directory that you decompressed the file to if it is different from mine.
  6. Now, before we can compile the source you need to configure the make files. To do this simply type ./configure --prefix=/usr. This will take a bit of time. I am assuming here that there were no errors and that the ./configure --prefix=/usr went ahead without issue.
  7. When the the ./configure --prefix=/usr completes you are free to go ahead and compile and install the source.
  8. To actually compile the XSP source you need to run the make command.
  9. Root privileges are required for the next step. If you have just installed Linux as a standalone machine you can usually give your account root privileges by typing the sudo bash command and entering the root password.
  10. Finally, to install, for lack of a better word, simply run the make install command. This will deploy the compiled binaries, libraries and other bits and pieces to the correct directories.

Congratulations. You should not have the XSP web server installed on your system. The next section looks at how to run and use the XSP web server.


Read | Code Project


 


 
Categories: Asp.Net/Web Services

Although you do not need to write overloaded operators every day, this feature certainly puts the latest version of VB.NET (whether you call it 2.0 or 8.0—there is some confusion in this area) on par with even the most powerful object-oriented languages. This article demonstrates a step-by-step process for writing custom operators, including a brief explanation for neophytes. Of course, if you didn't like VB.NET because of its differences from VB6, you probably won't get too excited about the ability to overload operators in VB.NET 2.0.


What Operators Are and Why You Overload Them


Programming has a rich history based in mathematics. Mathematics is steeped in meaningful symbols, operators, and operands. Operators are symbols that perform a function and operands are the things on which operators operate.


Operators typically indicate how many operands they use. Usually, you'll encounter unary, binary, and ternary operators. Unary means one operand, binary means two, and ternary means three. "Not" is an example of a unary operator; "+" is an example of a binary operator; and "?:" is an example of a ternary operator. (I have never seen a quaternary operator.)


Operators are convenient because they are quick to write and they are familiar, especially in arithmetic operations. For example, "&" and "+" are Boolean and arithmetic operators, but you can also used them to perform string concatenation for string operands. Clearly, operators have had multiple—or overloaded—meanings for some time. A natural evolution is this ability extending to us programmers.


Read | DevGuru


 
Categories: Asp.Net/Web Services


It seems that everyone is talking about making an SOA and how much it will improve their operations, yet most people are hard-pressed to define not only what an SOA is, but also to quantify what specific value it might provide to their organizations. Many simply assert that their SOA architecture comprises a group of Web services through which they can expose business logic over the Internet.

A service-oriented architecture is comprised of a number of different services that can be consumed by any number of clients. The only assumption made by either party is that communication takes the form of a well-defined and strictly enforced contract.

The purpose of this article is to describe a Service-Oriented Architecture (SOA) in terms of the IT industry. Unfortunately, the term SOA doesn't really have a formal definition. In fact, many people believe that SOA means you have several Web services exposed to clients. Although this is not necessarily wrong, it's not the whole requirement either.

An SOA is much more than mere Web services. In fact, Web services are not a requirement for implementing an SOA; an SOA is about architectural refinement rather than the implementation of one specific technology. This means that an SOA converts your architecture from isolated systems into black box services that can be reused without modification.

To fully implement an SOA, you must move from a monolithic application development model to a publisher/consumer application development model. Developing software to utilize formal contracts and become autonomous removes the dependence on elements outside of the formal contract. Companies developing applications around a publisher/consumer model will find themselves with a flexible architecture, one that is able to provide a large amount of functionality without compromising the core of the system.

Read | Devx


 
Categories: Asp.Net/Web Services

ASP.NET 2.0 introduces the ability to have an ASPX page postback to a different ASPX page with cross page postbacks. This was done all the time in ASP but wasn't supported in ASP.NET 1.x. This wasn't directly supported because on the server you need the same page to be recreated upon postback so the same controls could be repopulated with the post data. Since the model is to work at a higher level with server side controls and their properties, posting back to a different page would force you to access Request.Form to fetch the data a user had entered, which is a lower level than the control model wants.


So, in v2.0 they came up with a way to support cross page postbacks. This is enabled by a button on the first page setting PostBackUrl property to the page that will handle the postback. Once in the second page you can access the controls from the previous page by accessing the Page.PreviousPage property. Here's a sample that's like most of the documentation I've seen:


// Page1.aspx
<form id="form1" runat="server">
    <asp:TextBox runat="server" ID="_tb1"></asp:TextBox>
    +
    <asp:TextBox runat="server" ID="_tb2"></asp:TextBox>
    <asp:Button runat="server" ID="_button"
                PostBackUrl="~/Page2.aspx" Text=" = " />
</form>

// Page2.aspx
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
    TextBox tb1 = (TextBox)PreviousPage.FindControl("_tb1");
    TextBox tb2 = (TextBox)PreviousPage.FindControl("_tb2");
    int sum = Int32.Parse(tb1.Text) + Int32.Parse(tb2.Text);
    _result.Text = sum.ToString();
}
</script>
<form id="form1" runat="server">
    Answer is: <asp:Label runat="server" ID="_result"></asp:Label>
</form>

I find this to be entirely too tedious primarily because this approach still loses out of the declarative server side object model. The second page has to re-declare the same controls as local variables to access the properties. I don't think it will be how people write their second page to handle the postback. Instead the more useful approach will be to use the <%@ PreviousPageType %> directive in the second page:


// Page1.aspx
<script runat="server">
public int Sum
{
    get
    {
        return Int32.Parse(_tb1.Text) + Int32.Parse(_tb2.Text);
    }
}
</script>

<form id="form1" runat="server">
    <asp:TextBox runat="server" ID="_tb1"></asp:TextBox>
    +
    <asp:TextBox runat="server" ID="_tb2"></asp:TextBox>
    <asp:Button runat="server" ID="_button"
                PostBackUrl="~/Page2.aspx" Text=" = " />
</form>

// Page2.aspx
<%@ PreviousPageType VirtualPath="~/Page1.aspx" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
    _result.Text = PreviousPage.Sum.ToString();
}
</script>
<form id="form1" runat="server">
    Answer is: <asp:Label runat="server" ID="_result"></asp:Label>
</form>

The first page utilizes the posted data via the declarative controls and it provides the necessary information to the second page a public property. Now this is much better since we now get to reuse the declarative controls. I really think this will be the preferred style of using cross page postbacks in ASP.NET 2.0.


One very interesting thing I've noticed about cross page postbacks is the life cycle of the first page when posting back to the second. The first time the second page accesses Page.PreviousPage ASP.NET needs to make a page object available. So it, in essence, creates the Page.PreviousPage object and calls ProcessChildRequest , which is similar to ProcessRequest except it stops processing prior to PreRender and a fake Response object is created so that no Write s are emitted. This has some interesting side effects, one of which is that all of the server side events of the first page fire. This includes Page_Init , Page_Load and any control events like Button.Click events (if the Button has an OnClick event declared). This blew me away and it's certainly something to keep in mind when using cross page postbacks. One way to detect if your page is being accessed as a PreviousPage is to check Page.IsCrossPagePostBack .


One last thing to note about cross page postbacks is that using tracing is a PITA, since the PreviousPage's Trace messages end up mixed with the current page's Trace messages.


 
Categories: Asp.Net/Web Services

Introduction

Windows XP Media Center Edition 2005 is an exciting platform for enjoying all of your media from the comfort of your sofa. However, there are many times that you might wish to extend Media Center to perform functionality that it does not have "out of the box." Microsoft has created a software development kit that allows you to write your own software that runs in Media Center. In a previous article, I gave you a broad-brush introduction to creating an HTML application that runs in the 10-foot experience of Windows Media Center. This article will introduce you to the creation of .NET add-ins that are hosted within Media Center. The .NET add-ins allow you to write functional code that can interact with Media Center using your favorite .NET language.

There are two types of .NET add-ins for Media Center:



  • Background--runs at Media Center startup and remains running in the background
  • On-Demand--executed in response to some action from the user
Getting Started

One of the first things you need to know about creating add-ins for Windows XP Media Center Addition 2005 is that they must be written and compiled in .NET 1.0. This is due to the fact that the add-in is hosted by the Media Center process, and that's the only version that Microsoft supports at the present time. This causes many developers a little discomfort, because they are accustomed to working with Visual Studio 2003, which supports only .NET 1.1. However, you can continue to use your existing editor of choice to write the code and then use the .NET compiler on the Media Center computer to compile it. That is the approach that I'll take in this article so that you can get a quick feel for developing an add-in for Media Center without having to install an older version of Visual Studio.


Before we get started, make sure you've downloaded and installed the Media Center Software Developer Kit (SDK).

Required Interfaces

In order to allow your class to interact with Media Center, you need to be familiar with two interfaces:



  • IAddInModule--Media Center uses this interface to trigger your add-in to initialize and uninitialize. It has two methods:

    • Initialize--called when the add-in is first loaded
    • Uninitialize--called when Media Center wants to shut down your add-in

  • IAddInEntryPoint--This is the main interface that Media Center uses when it launches your add-in. All add-ins must implement this interface. It has a single method:

    • Launch--Called after your add-in has been initialized, this is where your primary execution logic should go. Think of it as the old reliable Sub Main in Visual Basic.

[Read More]


 
Categories: Asp.Net/Web Services

May 15, 2005
@ 09:35 PM

Nikhil Kothari has developed a browser extension for Internet Explorer that shows debug/trace information useful for ASP.Net developers.  The Plugin also displays the decrypted content of the application's viewstate.  For security purposes the app only runs for sites being developed on the local machine -- localhost.  You can find out more about the app and download it from his blog at http://www.nikhilk.net/Entry.aspx?id=63.


[Via Andrew Connell]


 


 
Categories: Asp.Net/Web Services

Microsoft and Sun Microsystems said they were nearly ready to release products that help bridge the gap between their operating systems, a result of their legal settlement more than a year ago.

Microsoft and Sun in April 2004 agreed to settle a years-long battle, with Microsoft paying $2 billion to Sun to resolve the dispute in a 10-year technical collaboration agreement.

The two companies announced new plans that would allow a Web-based single sign-on between systems that use both Microsoft and Sun , potentially eliminating the need for multiple user names and passwords for different computer systems and software programmes.

”These are huge messages to our employees and to our customers that we’re working together,” Sun Chief Executive Officer Scott McNealy said in a joint news conference with Microsoft CEO Steve Ballmer.

Microsoft and Sun will ultimately submit the new specifications to a standards organisation for finalisation and for ratification as industry standards. Ballmer and McNealy also said the two are working together on systems management software that will bridge differencs between operating systems and management software.

As part of that effort, the firms are collaborating on the development of WS-Management, a Web services specification co-authored by Microsoft, Intel and other companies that defines a single protocol to meet systems management requirements spanning different types of hardware, operating systems and applications.

“We’ve been hard at work, the two companies, for a year,” said Ballmer. “We’re poised to leave the computer lab now and enter the marketplace.”


[Via The Economic Times]


 
Categories: Asp.Net/Web Services

This is a brief article on getting started with writing unit tests. Rather than getting into coding and the 'how to's, of which there are numerous introductory tutorials, I want to discuss more the zen of unit testing. Hopefully you will find the information here to be of value--specifically, getting the most out of writing unit tests when you haven't ever done it before. I've written a lot of articles on unit testing, but frankly, I don't think they really provide enough guidance for the beginner.


[More]


 
Categories: Asp.Net/Web Services

April 27, 2005
@ 07:34 PM

Checkout Bill's Keynote from WinHec.  In his keynote presentation, Microsoft Chairman and Chief Software Architect Bill Gates reflects upon the hardware industry over the last 20 years and how the introduction of 64-bit and multicore computing will create a wave of industry innovation. Gates also provides a view into the foundation being laid for the release of Microsoft Windows "Longhorn."


[See Video]


 
Categories: Asp.Net/Web Services

Last Chance to Register – Be sure to attend MEDC 2005, the premier opportunity to share and learn more about the latest Windows Embedded and Windows Mobile platforms.






Right-click here to download pictures. To help protect your privacy, Outlook prevented automatic download of this picture from the Internet.
Click here to Register Now
Registration ends May 5, 2005, at 11:59pm (PST)


Just Announced! Attend These Breakout Sessions:

MEDC 2005 offers several new sessions this year on developing for Windows Mobile and Windows Embedded, including:


Developing High Performance Applications with the .NET Compact Framework
Want to learn how to write high performance .NET Compact Framework applications? Hear from the experts on how to design and build your .NET Compact Framework applications for maximum performance and efficiency. Build performance into your applications right from the start.


Increasing Developer Productivity with Platform Builder 5.0
Learn how to leverage Platform Builder 5.0's new Unified Build architecture to increase time to market. Learn how to build targeted areas quickly, perform mixed mode builds (retail and debug), clone OS code, and rebuild/debug modules without rebuilding images or re-flashing devices.


Exploring the Dirty Details of Building a Database Driven Application using Visual Basic® .NET and SQL Server™ 2005 Mobile Edition
In this session we'll demonstrate how to use features of Visual Studio® 2005 to build a DVD catalog application using SQL Server™ 2005 Mobile Edition. We'll also dig into the source code and discuss accessing data, passing information between forms, and building UI that meets Windows Mobile design guidelines.


Plus: Hear from Microsoft Chairman and Chief Software Architect Bill Gates.

Visit www.medc2005.com for complete session and conference information.


Join us at MEDC 2005. Register Now.


 
Categories: Asp.Net/Web Services

April 19, 2005
@ 10:48 PM
by Bill Lodin

The past seems to be popular these days. From VH1's nostalgia-laced "I Love the 70's, 80's, and 90's" shows to the popularity of "classic" musical artists (U2, Bruce Springsteen and the Rolling Stones coming soon to a city near you), retro is in. They're feeling a wave of nostalgia up at Microsoft too. But in Redmond, this wave marks the return of the rich client.


No, not the rich client you're familiar with—rich clients now have gotten "smart." How? In part, by the lessons learned in thin-client development. Over the past 10 years, Web application development has become the de facto standard for most programmers. "Thin was in," and we developers responded by dutifully learning our ASPs, J2EEs and PHPs.


So What's Wrong with Thin Clients?
In a traditional thin-client application, users navigate through a series of Web pages to perform tasks, and these tasks are realized primarily through server-side business logic.


What's wrong with this picture? Well, two things, really. First of all, despite the amazing things that we've been able to accomplish inside the browser, we still have to operate inside the browser. This creates some fundamental limitations to creating a rich user interface.


Secondly, the fact that our business logic exists on the server means that connectivity is essential. Lose the connection and the application is unavailable -- and work doesn't get done. Sure, we can focus our attention on improving server uptime, but typically some parts of the connectivity story are beyond our control (ever have your ISP decide to perform maintenance on your connection right before a deadline?) Besides, what about predictable situations in which connectivity is not present, as when a user wants to continue working while on a plane or at a remote job site?


More...


 
Categories: Asp.Net/Web Services

The recommended way to create cross-language Web sites is to localize using .NET's support for culture codes. Here are some examples of culture codes:



  • en-US: "en" represents the English language. "en-US" provides a specific culture, that is, the culture representing English used in the US
  • en-GB: This culture code represents the English language used in Great Britain.
  • fr-CA: This culture code represents the French language in Canada.
  • zh-CN: This culture represents the Chinese language used in the People's Republic of China.
The localization process involves tasks such as:



  • Date formatting. People in the United States represent dates in a different format from someone in, say, the United Kingdom. Does "2/7/2004" represent the 2nd of July, 2004, or does it represent February 7th, 2004? The answer depends on where you are located.
  • Changing displayed text from one language to another. For example, the text in your application must change to Chinese if you are targeting the Chinese market.
  • Text direction. Does text read from left to right or from right to left?
As a developer, you need to be concerned with the following:



  • Globalization. When designing your application, you plan for all the necessary resources needed to enable your application to be modified with ease to suit different cultures.
  • Localization. You perform the actual transformation to ensure that the user sees the application using the culture he/she has selected.

In this article, I will discuss the localization feature in ASP.NET 2.0 (based on Beta 1) and how it simplifies the task you need to perform to create international applications.

Localization Basics
Before we see how ASP.NET 2.0 makes localization easy, let's understand some basics in localization. A culture is a way to identify a particular setting pertinent to a location or country. You use a culture code to represent a culture.

A neutral culture represents a culture that is associated with a language but is not specific to a particular location. For example, "en" is a neutral culture, because it represents the English language but does not provide a specific instance of where it is used.

A specific culture is a culture that is specific to a region or country. For example, en-GB is a specific culture.

Finally, the invariant culture is neither a neutral nor specific culture. It is English, but is not associated with any location. The invariant culture is used to represent data that is not shown to the user. For example, you use the invariant culture to persist date information to a file. This ensures that the date information would not be misrepresented if is it going to be interpreted in another specific culture.


More...


 
Categories: Asp.Net/Web Services