MsgBox From ASP

To show message box from applications is not as easy as we do in Visual Basic for win forms. We have to do it in client scripting so we are using javascript to create an alert. We are using the same naming as we do in classic visual basic. the code is below.

We can do the same in the client scripting directly in the markup. But several times in an application we may need to handle this in a code behind so it is always useful to have a helper method in the serverside to show alerts

Source Code

Sub MsgBox(strMsg )
 Dim strScript
        strScript = "<script language='Javascript'>"
        strScript &= "self.alert('" & strMsg & "')" ...

Read more here:   MsgBox From ASP 


Simple Guestbook Html Code with File System

If the website is designed and developed only in plain HTML, it is nearly impossible to create a Guest Book with just plain HTML in server to track the guests. But now a days it is easier to find an ASP hosting for cheaper prices. It should be noted that, the server side execution is required for saving a GuestBook. Though the databases are the way to go. To make the article simpler I have used a flat file for GuestBook. As the target of this article is not providing a full working application for GuestBook, I am just writing some code for beginners to learn how to start with.

Guestbook Html Code To write into File System

As we discussed little earlier, the guest book is going to be saved into the file system. Since the flat file is just a text storage, we need to delimit t ...


Debug Issue Register IIS

Error while trying to run project:

Unable to start debugging on the web server. The server does not support debugging of ASP.NET or ATL Server applications. Run setup to install the Visual Studio .NET server components. If setup has been run, verify that a valid URL has been specified.

You may also want to refer to the ASP.NET and ATL Server debugging topic in the online documentation. Would you like to disable future attempts to debug ASP.NET pages for this project?


Open command window by Start > Run then type cmd and hit enter

Locate the directory in command prompt using cd command C:\[Windows Directory]\Microsoft.Net\Framework\[Version]

Note: You must replace [Windows Directory] in this path with the correct directory for your system and replace [Version] with the version of the .NET Frame work installed on your system.

Execute aspnet_regiis -i to re-register the ...

Read more here:   Debug Issue Aspnet_regiis 


ASP.Net Image Dropdownlist using Repeater

I was searching for ASP.Net Image Dropdownlist that can have a image thumbnail before the text in each item in the list. However, we do not have any option ASP.Net Image Dropdownlist that can contain image thumbnails. WPF does but not ASP.Net. Hence, I started planning to build one for my project. However, it is not a user control or server control. This can be made as server control with necessary changes but this article will be big. I would like to keep it simple and to explain how this can be achieved.

Constructing the Image Dropdownlist

 I was interested in showing this as close as possible to the standard Dropdownlist. I planned to have three main components to construct. The following are the list and hierarchy of the controls used

• Dropdownlist as a HTML DIV
a. Image to show the selected item’s Image
b. Label to show the selected item’s text
c. Button to s ...

Read more here:   Asp.Net Image Dropdownlist 


ASP.Net Menu And CSS to format

Without a menu the web application is hard to navigate. We can even bind to a hierarchical data. Or with little additional work the database tables can be bound easily.

Format Base Menu

Base menu can be formatted using some simple format options(similar like anyother controls in shown as below). But the important item to be noted is the section where this is applied for. To format base menu use LevelMenuItemStyles section(BackColor="Silver" BorderStyle="Dashed" BorderWidth="1"). If  the menu has to be displayed horizontally, the orientation attribute has to be changed accordingly(Orientation="Horizontal") which is availabel in the <asp:Menu section itself

Sample grey background style will look like
<LevelMenuItemStyles >
<asp:MenuItemStyle BackColor="Silver" BorderStyle="Solid" Font-Bold="true" BorderColor="Gray" BorderWidth="1" HorizontalPadding="10px" />
</LevelMenuItemStyl ...

Read more here:   Formatting items in ASP.Net Menu 


Package multiple files using Asp.Net Zip

Microsoft.Net has a very good utility for zipping aka packaging files. While there are good utilities there in open source/Code Plex for packaging files. I would still prefer to write the code using native functions and classes available in .Net. In this article I am going to use the System.IO.Packaging for showing how to attach multiple files into a zip.

Zipper class for Packaging

I have created a separate class called as Zipper for the future works as it gives great re-usability.  This class can be used for the WinForms, WPF, or ASP.Net applications. Though has to be changed as per the specific needs. It is just a starter for writing more functions into the zipper class.

Referencing required assemblies

The System.IO.Packaging library is not directly available in the default set of references. You have to add a reference to the assembly known as windowsbase.dll under Program Files. In my system it is ...

Read more here:   Asp.Net Zip Multiple Files 


How to build a Horizontal List using an Repeater

Have you ever tried generating a horizontal list in ASP.Net?  There is no control in ASP.Net which natively supports this (to my knowledge).  Radio button list supports the list’s orientation as horizontal. But you can not use radio button list for a menu. I am trying to use a repeater to fabricate the menu so that you can add the other onClick events later to bind to the respective actions.

Why ASP.Net over the other data controls. repeater is a very simple control which just repeats the items defined in the ItemTemplate. It does not add anything other than this. This gives us more possibilities in generating the code as we like. And for this menu we don’t need any paging or runtime sorting options. So with a little CSS and JavaScript we are ready to use the horizontal menu we created.

Bind the Data

Please refer to the data controls section for how to connect the data and ...


Cascading Dropdownlist in Asp.Net

There are various ways to get the cascading dropdown in the But the following is highly performance oriented approach. For fetching data the data is transferred from web server to client using web service. So the data transfer between server and client is very minimal. Thus you can experience the cascading very fast for a small to medium size of data.

This article needs Ajax Control kit. It needs to be downloaded separately.
Once downloaded, create a new website and select the Default.Aspx and then switch to design mode in the Web Form

Cascading DropDownlist In Web Form

While in design mode, open the tool box and right click and choose items. In the “Choose Toolbox Item” choose the downloaded AjaxControlToolKit.dll.

Now you will see a list Ajax controls in the tool Box.

Drag the Cascading Dropdown to the Web form.

Right click the website and add a web service named Northwind ...

Read more here:   JavaScript Ajax Cascading Dropdown 


Load data from Stored Procedure

Loading data from stored procedures is essential for data bound applications. Executing stored procedures and retrieving data is not that difficult. With the use of SQL Command and SQL Data Adapter we can fill either a dataset or a strongly typed dataset.

Setting up Sample Code

I use Northwind sample database provided by Microsoft for sample source code in this website. So to run this code you need to download it from MSDN. After downloading, there will not be any stored procedure which is explained in this sample. So I have added SQL server stored procedure script with this sample code. So run this script to get the stored procedure inside the Sample DB before running the sample code.

Load Data using a SQL Adapter

As I explained earlier we need a SQL Command and parameters to form the Command. Then we have to use the SQL Adapter to execute the prepared command. First we need to add the necessary parameter ...


Use Parameters in Stored procedures

Using stored procedures in application helps in various ways to run couple of SQL statements, and makes the applications to get the data by calling those procedures. When using stored procedures, the parameters have to be sent to while executing the stored procedures.

SqlParameter to pass the value

Since most of the samples I am working on are related to SQL Server, I need to use the SqlParameter. There are various ways to pass the values from (or win forms, WPF applications, win service, etc...) applications.  I prefer just create a new parameter by specifying its name and type while initializing and then pass the value using the value parameter.

Stored procedure

Stored procedures which are accepting the parameters have to specify its datatype and the length of the data. If you are expecting that there will be a possibility that the parameter may not be passed at all i.e. the opt ...


Spam Bot Trap


Select Theme