background preloader

.net development

Facebook Twitter

How to Use RegisterClientScriptBlock & RegisterStartupScript. Introduction One example of using the RegisterClientScriptBlock and RegisterStartupScript demonstrates injecting client side script from an ASP.NET Server Control. When developing ASP.NET server controls, you should ask yourself how you could enhance the usability through the use of client-side script. Once you have identified these areas, all that remains is to augment the server control so that it emits the proper client-side script.

Now here, I am going to show an example that will populate states in a dropdown menu related to their respective country. Description Now that code, using a DataSet, has generated two arrays of strings: i.e., CountryCode & StateName. The Join() method is static, requiring the String type identifier, rather than a String instance, to implement the command. String.Join("','",StateName) is the function that converts an array of string into a single string separated by commas. First of all, I am populating data on client side. The Base Control.

Walkthrough: Creating a Basic Web Page in Visual Studio. The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location. This walkthrough provides you with an introduction to the Web development environment in Microsoft Visual Studio 2010 and in Microsoft Visual Web Developer Express. This walkthrough guides you through creating a simple ASP.NET Web page and illustrates the basic techniques of creating a new page, adding controls, and writing code.

Tasks illustrated in this walkthrough include: Creating a file system Web site project.Familiarizing yourself with Visual Studio.Creating a single-file ASP.NET page.Adding controls.Adding event handlers.Running pages by using the Web server that is built into Visual Studio for testing. In order to complete this walkthrough, you will need: Microsoft Visual Studio 2010 or Microsoft Visual Web Developer Express. In this part of the walkthrough, you will create a Web site project and add a new page to it. Beginners guide to accessing SQL Server through C# Introduction In this article I plan to demonstrate how to insert and read data from a SQL Server or MSDE database. This code should work on both SQL Server , I am using 2000, and MSDE. I am using Visual Studio 2002, but this should work with Visual Studio 2003, Web Matrix, and the command line SDK. This code should work with both C# applications and C# web applications and webservices.

This code does not compile on the FreeBSD with Rotor [^]. Background Part of my current project required me too store and retrieve information from a database. Using the code I did not include a sample application because the code provide within the article can really be dropped in and should work with no problem. Making the Love Connection There is no real voodoo magic to creating a connection to a SQL Server assuming it is properly setup, which I am not going to go into in this article, in fact .NET has made working with SQL quite easy. Using System.Data.SqlClient; SqlConnection.ConnectionString User ID.

[Solved] Call to javascript Function from code behind using ScriptManager.RegisterStartupScript. Geocoding-net - C# GeoCoding / Address Validation API. HTML to XHTML Conversion with SGMLReader. This is a web - based implementation of converting HTML to well-formed XHTML using Chris Lovett of Microsoft's excellent SGMLReader. Chris's code has a command - line interface; however I needed an in-memory implementation for some work we're experimenting on that takes well-formed XHTML and converts it to RTF for display in a RichTextBox control. There are many other uses for XHTML compliant HTML, not the least of which is the fact that an XHTML page is a legitimate, well-formed XML document, which opens up a whole new range of possibilities for HTML processing when you think about it...

There are a lot of interesting uses for this type of utility. The result can be saved with an XSL extension, and you are on your way to creating your XSL Stylesheet for your XML Transformation to create dynamic web pages! And now for the fun part. Try the HTML to XHTML web page As always, the full solution may be downloaded from the link below. Download the code that accompanies this article. MSDN Blogs. Recently I've been scouting around Stack Overflow looking for Open XML-related questions - it's always interesting to see what real people are doing with technologies you've been involved in. One topic that often comes up is the question of how to create SpreadsheetML files from scratch. The way most people go about this is to save a blank file directly from Excel and then, using the Open XML SDK, open that template file, insert your necessary data into it and save it as the destination output file.

While this works fine I can't help feeling it's a little inelegant. Why not create a file from scratch? The Open XML SDK comes with a great tool called the Reflector. You can open a file, click "Reflect code" and it'll generate the code necessary to create that file. I saved a blank file from Excel, and then opened it in the reflector.

It turns out that a "blank" file saved by Excel contains a lot of data that isn't required by the standard. Without further ado, here is the code. How to: Host a WCF Service in a Managed Application. Walkthrough on creating WCF 4.0 Service and Hosting in IIS 7.5. Objective This article will give step by step walkthrough 1. How to create a basic WCF 4.0 Service? 2. How to host WCF Service in IIS 7.5? 3. Create WCF Service Create WCF service. Delete the default code created by WCF from IService1 and Service1.svc.cs a. B. IService1.cs using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace WcfService5 [ServiceContract] public interface IService1 [OperationContract] string GetMessage(); Service1.svc.cs public class Service1 : IService1 public string GetMessage() return "Hello From WCF Service "; Leave the default configuration created by WCF.

Web.Config Host WCF Service in IIS 4.0 Open IIS a. Now you will have IIS open like below b. C. Give any name of your choice as the site name. Now click on select and choose ASP.Net v4.0 from the drop down. Now in the physical path section, we need to give physical path of the service. D. E. A. B. C. D. A Beginner's Tutorial on How to Host a WCF Service (IIS Hosting and Self Hosting) Download sample - 61.5 KB Introduction In this article we will see how we can host a WCF service. We will look at various ways a WCF service can be hosted and what are the benefits and drawbacks of each hosting method. We will also create a sample client application that will consume the WCF service hosted in different ways. Background This article assumes that reader has some basic knowledge of WCF services. In a service oriented architecture the standalone service is of no use unless it is exposed to the client. Traditional web services were hosted on IIS. WCF comes with the possibility of being invoked and used by protocols other than HTTP.

A WCF service can be hosted in following ways: Hosting in Internet Information Services(IIS). Hosting in Windows Activation Services(WAS). Hosting in a Console or Desktop application(Self hosting). Hosting in a Windows Service. Every method of hosting comes with its own benefits and drawbacks. Hosting a WCF service in IIS is perhaps the easiest method. WCF Templates and Tools. Articles in this series There are several Visual Studio templates available to help you to be more productive with WCF. In addition there are a few essential tools – some that are most useful as you are getting started, and others that you will use more regularly. In this section I will summarize the available project templates and when to use each; discuss some side-effects and workarounds; and discuss the limitations and benefits of the core WCF tools.

Creating WCF-Enabled Projects Getting started with WCF is easy when you use the new project and new web site templates listed in Figure 1. Figure 1: Visual Studio new project and new web site templates for WCF Figure 2: New project and new web site dialogs The main benefit of using these templates is to automatically add necessary assembly references, and to provide a sample WCF service with the associated <system.serviceModel> configuration to work with.

Adding WCF Services to a Project Figure 3: Visual Studio new item templates for WCF. A Beginner's Tutorial on How to Host a WCF Service (IIS Hosting and Self Hosting) REST vs. SOAP: How to choose the best Web service. "I need to update the local inventory database with the inventory information from multiple suppliers. The suppliers... By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA. You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy. provide Web service-based interface. Do similar questions trouble you? There is a different perspective, where the databases act as the service consumer in contrast to the normal norm of acting as a service provider.

Web services overview A Web service, in very broad terms, is a method of communication between two applications or electronic devices over the World Wide Web (WWW). REST vs. The RESTful Web services are completely stateless. Swati Dhingra asks: C# - How to add WCF templates to Visual Studio Express. Getting Started Tutorial. The topics contained in this section are intended to give you quick exposure to the Windows Communication Foundation (WCF) programming experience. They are designed to be completed in the order of the list at the bottom of this topic. Working through this tutorial gives you an introductory understanding of the steps required to create WCF service and client applications. A service exposes one or more endpoints, each of which exposes one or more service operations.

The endpoint of a service specifies an address where the service can be found, a binding that contains the information that describes how a client must communicate with the service, and a contract that defines the functionality provided by the service to its clients. All of the topics in this section assume you are using Visual Studio 2011 as the development environment. Amit Raya: Create Websites using SQL Express with ASP.NET MVC. I was trying my hand on learning ASP.NET MVC but one thing that create most problem for me was that most of the tutorials used SQL Compact (here after reffered as SQL CE). But I wanted to use SQL Express as my database server. I had to struggle a lot to find a way to make website using SQL Express and ASP.NET MVC. So I thought if I put it here it might help :) To start with this, we first need to create a solution in VWD 2010 with MVC. 1.

Create a project, choose a name for the project, for convenience I have named it "MvcTest". Click "Ok" button. 2. 3. 4. 5. 6. 7. The connection string to use SQL CE is: We add this connection string to web.config file on the root of the solution. To change the connection string to use SQLExpress we can use the following string: Now once the connection string is defined in web.config file, we need to build the solution before we proceed. 8. A. B. C. D. 9. 10. 11. A. B. C. D. Hope this post helps you to use SQLExpress with ASP.NET MVC :) C# - How to create WCF Service Library in Visual Studio 2010 Express. Blogs. This post has an easy goal – to get you up to speed quickly and teaching you the core concepts of WCF.

From this post you will be well primed to dive deep into more advanced topics, such as advanced bindings, channel layers, security, transactions, and more. The web service that we create will be capable of supporting three types of clients. The first client will simply leverage http to send and receive data. The second client may need to take advantage of security and transactions. And the third type of client wants to leverage fast machine to machine connectivity using TCP.

We will test for all the clients using the WCF Test Client. In the next post we will explore hosting this project in IIS or in your own custom application. Objectives In this hands-on lab, you will learn how to: Prerequisites The following is required to complete this hands-on lab: Setup In order to execute the exercises in this hands-on lab you need to set up your environment. Begin by starting Visual Studio Hosting WCF.