Web-based operating systems are more than just a collection of applications that run within a browser. They're self-contained environments in which you can create and store documents, copy files from one folder or drive to another, and conduct communications.
In short, almost everything you can do from Windows or the Mac OS should be able to be accomplished within a Web OS. All you need is a Web browser to get there.
One could argue that a Web-based operating system is redundant, since one needs a computer, operating system, and Web browser to access an online operating system. While that's true, the point of an online operating system is complete environment portability.
That means being able to log on to any computer that has an Internet connection and, in the time it takes to launch your Web OS, having all of your applications and documents ready for you to resume work. Although you could cobble together many of the elements of a Web OS by using, say, Google Docs, Yahoo Mail, and other online applications, doing so would require you to make several stops around the Internet.
There's no doubt that today's Web-based operating systems are far from feature-laden, and they probably will not tempt many to abandon their current routine that combines desktop and Web-based software.
But given the push that the major players in the industry are making toward a completely Web-based future, there's also little doubt that Web-based operating systems, or some form thereof, are in our collective future.
Here is the list of some web based OS to try with:
1. http://desktoptwo.com
2. http://g.ho.st/
3. http://eyeos.org
File upload error : "Can not access a closed file"
Reason:
This error occurs partily due to the new memory management feature added in the asp.net2.0 therefore you may wonder same code after migrating from asp.net1.1 to asp.net2.0 starts throwing this error.
As I said,new memory management feature is partily reposible because you may not get this error if you are uploading the file directly without any redirection(due to business requirement) for exp. - storing uploaded file object in the session on file upload page and saving it after user confirmation on the confirmation page.
Most likly you will get this error in the senario I mentioned as an example above subjected to the file size is more than 80Kb. The reason is,according to new memory management feature of asp.net2.0 when you upload a file the input stream is buffered in the memory if its size less than 80Kb otherwise it is stored in the temporary locations on the disk upto 4096Kb so when you maintain an object of any uplaoded file(more than 80Kb size) in session and redirect on different page the current request is disposed and the disk file associated with it is closed as well, now when you try to save uploaded file object on server(using SaveAs method of upload control) from the session, the request processing thread tries to read from the closed file object and thats where you get this error message.But if your uploaded file size is much less than 80Kb then you may not face this error.
Solution:
You can solve this issue by adding following tag in the web.config file of your website.
< httpRuntime maxRequestLength="10240" requestLengthDiskThreshold="4096"/ >
Note - change the values according to your requirement.
maxRequestLength - Specifies the total limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server.
The default is 4096 KB. If the threshold is exceeded, a ConfigurationErrorsException error is thrown.
requestLengthDiskThreshold- Specifies the limit for the input stream buffering threshold, in kilobytes, it means if size of the stream is more than the value specifed it is stored in the temporary location on the disk otherwise buffered in the memory. This value should not exceed the maxRequestLength attribute.The default is 80 KB.
Note - This attribute is new in the .NET Framework 2.0.
So, if you assign same value to both the attributes, your application process the file upload request just like asp.net1.1.
This error occurs partily due to the new memory management feature added in the asp.net2.0 therefore you may wonder same code after migrating from asp.net1.1 to asp.net2.0 starts throwing this error.
As I said,new memory management feature is partily reposible because you may not get this error if you are uploading the file directly without any redirection(due to business requirement) for exp. - storing uploaded file object in the session on file upload page and saving it after user confirmation on the confirmation page.
Most likly you will get this error in the senario I mentioned as an example above subjected to the file size is more than 80Kb. The reason is,according to new memory management feature of asp.net2.0 when you upload a file the input stream is buffered in the memory if its size less than 80Kb otherwise it is stored in the temporary locations on the disk upto 4096Kb so when you maintain an object of any uplaoded file(more than 80Kb size) in session and redirect on different page the current request is disposed and the disk file associated with it is closed as well, now when you try to save uploaded file object on server(using SaveAs method of upload control) from the session, the request processing thread tries to read from the closed file object and thats where you get this error message.But if your uploaded file size is much less than 80Kb then you may not face this error.
Solution:
You can solve this issue by adding following tag in the web.config file of your website.
< httpRuntime maxRequestLength="10240" requestLengthDiskThreshold="4096"/ >
Note - change the values according to your requirement.
maxRequestLength - Specifies the total limit for the input stream buffering threshold, in KB. This limit can be used to prevent denial of service attacks that are caused, for example, by users posting large files to the server.
The default is 4096 KB. If the threshold is exceeded, a ConfigurationErrorsException error is thrown.
requestLengthDiskThreshold- Specifies the limit for the input stream buffering threshold, in kilobytes, it means if size of the stream is more than the value specifed it is stored in the temporary location on the disk otherwise buffered in the memory. This value should not exceed the maxRequestLength attribute.The default is 80 KB.
Note - This attribute is new in the .NET Framework 2.0.
So, if you assign same value to both the attributes, your application process the file upload request just like asp.net1.1.
~ 18 comments: ~
How to partition external hard drive?
If you are using Windows XP then you can use DISKPART utility, which is the replacement of FDISK(Windows 95/98) utility. This is a command line disk management utility.
To run this utility, either open the console window and type DISKPART at the command prompt or use Run application.When you run this utility at the command prompt the prompt is changed to DISKPART prompt.
Here is the list of some useful diskpart commands.
1. Help - To see the help
2. Exit - To exit from the utility
3. List disk - To see the list of available hard disks
4. List Partition - To see the list of available partitions on the selected disk
5. Select Disk < disk number > - To select the hard disk for creating partitions
like - DISKPART> Select Disk 0
6. Create partition - To create partitions
7. Delete partition - To delete partitions
8. Assign letter=< Alphabate > - To assign letter to the partition
like -
DISKPART>list disk
DISKPART>select disk 1
DISKPART>list partition
DISKPART>select partition 1
DISKPART>assign letter=D
And there are many more command that you can check with help command.
Before going with this utility for partitioning you must decide how many partition of what size you want to create. For example I have 160GB external hard disk and I want to create 3 partitions of 50GB,50GB and 60GB.
First, I will connect my external hard disk with my PC.
Second, I launch diskpart utility at the command prompt and type in following commands at the diskpart prompt
in the same sequence.
1. DISKPART>list disk
2. DISKPART>select disk 1
3. DISKPART>create partition primary size=50000
4. DISKPART>create extended
5. DISKPART>create partition logical size=60000
6. DISKPART>create partition logical
In step 2 - disk 1 is my external hard disk
In step 3,5 - size is in MB
In step 6 - remaining size will be consumed
Note: After completing partitioning, disconnect external hard disk and re-connect it.
Now I will have to format these newly created partitions in order to use them for data storing.For that I use Window XP Disk Management utility.
Following are the step for accessing Disk Management utility.
1. Right click on My Computer icon on the desktop and select manage from the shortcut menu.
2. Now select Disk Management from the tree menu in the Computer Management window.
To run this utility, either open the console window and type DISKPART at the command prompt or use Run application.When you run this utility at the command prompt the prompt is changed to DISKPART prompt.
Here is the list of some useful diskpart commands.
1. Help - To see the help
2. Exit - To exit from the utility
3. List disk - To see the list of available hard disks
4. List Partition - To see the list of available partitions on the selected disk
5. Select Disk < disk number > - To select the hard disk for creating partitions
like - DISKPART> Select Disk 0
6. Create partition - To create partitions
7. Delete partition - To delete partitions
8. Assign letter=< Alphabate > - To assign letter to the partition
like -
DISKPART>list disk
DISKPART>select disk 1
DISKPART>list partition
DISKPART>select partition 1
DISKPART>assign letter=D
And there are many more command that you can check with help command.
Before going with this utility for partitioning you must decide how many partition of what size you want to create. For example I have 160GB external hard disk and I want to create 3 partitions of 50GB,50GB and 60GB.
First, I will connect my external hard disk with my PC.
Second, I launch diskpart utility at the command prompt and type in following commands at the diskpart prompt
in the same sequence.
1. DISKPART>list disk
2. DISKPART>select disk 1
3. DISKPART>create partition primary size=50000
4. DISKPART>create extended
5. DISKPART>create partition logical size=60000
6. DISKPART>create partition logical
In step 2 - disk 1 is my external hard disk
In step 3,5 - size is in MB
In step 6 - remaining size will be consumed
Note: After completing partitioning, disconnect external hard disk and re-connect it.
Now I will have to format these newly created partitions in order to use them for data storing.For that I use Window XP Disk Management utility.
Following are the step for accessing Disk Management utility.
1. Right click on My Computer icon on the desktop and select manage from the shortcut menu.
2. Now select Disk Management from the tree menu in the Computer Management window.
~ 1 comment: ~
How to publish multiple websites in a solution?
By default you can publish only single website at a time unless there is a dependency on other websites in a multiple websites in a solution. So if you want that along with your startup website other website should also publish then you will have to do some project dependency settings on the solution level.
Following are the steps:
1. Right click on the solution and choose Project Dependencies from the short-cut menu.
2. In the Project Dependencies window go to Dependencies tab.
3. Choose your main website(startup) from the 'Projects" dropdown.
4. Check all the other websites/web servies in the "Depends on" section that you want to publish along with your main website and click on Ok button.
Now when you publish your main website, you will be prompted with publish windows for all the depended websites for publishing.
But if you want to publish only startup website but you are prompted with other webistes/web servies publishing windows as well, which you dont want to publish then remove them from the dependency list of the startup website through above mentioned steps.
Following are the steps:
1. Right click on the solution and choose Project Dependencies from the short-cut menu.
2. In the Project Dependencies window go to Dependencies tab.
3. Choose your main website(startup) from the 'Projects" dropdown.
4. Check all the other websites/web servies in the "Depends on" section that you want to publish along with your main website and click on Ok button.
Now when you publish your main website, you will be prompted with publish windows for all the depended websites for publishing.
But if you want to publish only startup website but you are prompted with other webistes/web servies publishing windows as well, which you dont want to publish then remove them from the dependency list of the startup website through above mentioned steps.
~ No comments: ~
How to execute exe file in a web application
First of all we need to understand that under the existing web request process mechanism you can not make any executable application that exists on the web server execute on your machine(client machine) by requesting web server through IE. If your requirement is anything like this then better use Citrix Presentation Server.
Having said that, if you want to execute any executable program from you web application then you can try below given code in you web page.
Note – the exe will run on the server machine not on the client and you would not get any GUI.
//C# code
ProcessStartInfo MyProcess = new ProcessStartInfo();
//path of the program exe file
MyProcess.FileName = @"c:\myprogram.exe";
//pass parameter if you’re executable require any command line argument
MyProcess.Arguments = @"anyparam";
Process.Start(MyProcess);
Having said that, if you want to execute any executable program from you web application then you can try below given code in you web page.
Note – the exe will run on the server machine not on the client and you would not get any GUI.
//C# code
ProcessStartInfo MyProcess = new ProcessStartInfo();
//path of the program exe file
MyProcess.FileName = @"c:\myprogram.exe";
//pass parameter if you’re executable require any command line argument
MyProcess.Arguments = @"anyparam";
Process.Start(MyProcess);
~ No comments: ~
Licensing for ActiveX Components
There are 2 types of licensing schemes for ActiveX controls.
1.Design time – implemented using LIC Files.
2.Run time – implemented using LPK (License Package File) files.
If you are using licensed ActiveX control for the development purposes then you would need LIC file to load it in the development environment like Visual Studio or MS Access etc. And if you are using it in the web application then you would need LPK file to run it in the web browser like IE etc.
In every ActiveX control licensing is implemented by implementing methods of IClassFactory2 interface, which is built upon IClassFactory interface. These interfaces provide methods that are used for verifying licensing information during the instantiations of the control both in the design time as well as run time. Some of the methods are: GetLicInfo, RequestLicKey, andCreateInstanceLic etc.
Design-Time Licensing:
In the design environments like Visual Studio or MS Access etc, when you try to place ActiveX control on the form or web page or create instance of the control, one or more of these methods are called to verify the licensing information from the license file (.Lic file) and upon verification the control is instantiated.
Run-Time Licensing:
Run time licensing differs for execution environments like Visual Studio or MS Access etc and Internet Explorer. In case of VS, license keys of the ActiveX controls used in the application are embedded in the executable file (.exe file) of the application whereas for Internet Explorer license keys of ActiveX control are stored in the license package file(.Lpk file).
In case of Visual Studio or MS Access, run time licensing is almost same as design time licensing. During the execution of application licensing information embedded in the exe file is verified by one or more methods of IClassFactory2 interface against the licensing information stored in the controls used in the application.
In case of Internet Explorer, licensing scenario is bit different specially when you are distributing ActiveX control (see my earlier post on How to redistribute ActiveX control with Web Application
) due to following reasons:
1.ActiveX control is executed in the remote client machine where as the host application exists in the server machine.
2.Due to the openness of the delivered HTML source code, licensing information can not be embedded in the server response.
So, due to the above scenario, run time licensing is implemented with a new file called the license package file (or LPK file). This file can be included in any HTML page by using the object tag.
Example:
< OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331" >
< PARAM NAME="LPKPath" VALUE="LPKfilename.LPK" >
< /OBJECT >
Note- CLASSID is the class ID of ActiveX License Manager component.
The above mentioned object tag embeds ActiveX License Manager, which is a component of Internet Explorer 4.0 found in the Licmgr10.dll file. This component parses an .lpk file and extracts the license key for each corresponding CLSID in the file. Remember, this tag should be added before the codebase tag for the control distribution.
At run time, when Internet Explorer 4.0 is rendering an HTML page that contains ActiveX Controls, the License Manager calls the IClassFactory2::CreateInstanceLic method, passing the license key that it extracted from the .lpk file in order to verify that a control is licensed. If the license key matches the control's license, the control will be rendered on the page.
Note: - LPK file should exists at the root of the application in the hosting server. Although you can add multiple lpk files in the web page but only first one will be considered by IE. Licensing information of all the licensed controls used in a page should be added in a lpk file embedded in that page.
Create license package file (.lpk file):
LPK file can be created using a utility named License Package Authoring Tool (Lpk_Tool.exe) that can be downloaded from the download section of this blog.
The application is actually simple to use. When you start the application, it displays a combo box that lists all of the ActiveX Controls currently running on your computer. The next step requires that you choose the controls that you want to display on a given HTML page. You choose a control by highlighting it in the combo box and then clicking the Add button. Once you've selected all the controls that you want to display on a given page, you can create and save the actual .lpk file by clicking the Save & Exit button.
References:
http://msdn.microsoft.com/en-us/library/aa231198(VS.60).aspx
http://msdn.microsoft.com/en-us/library/aa751973(VS.85).aspx
1.Design time – implemented using LIC Files.
2.Run time – implemented using LPK (License Package File) files.
If you are using licensed ActiveX control for the development purposes then you would need LIC file to load it in the development environment like Visual Studio or MS Access etc. And if you are using it in the web application then you would need LPK file to run it in the web browser like IE etc.
In every ActiveX control licensing is implemented by implementing methods of IClassFactory2 interface, which is built upon IClassFactory interface. These interfaces provide methods that are used for verifying licensing information during the instantiations of the control both in the design time as well as run time. Some of the methods are: GetLicInfo, RequestLicKey, andCreateInstanceLic etc.
Design-Time Licensing:
In the design environments like Visual Studio or MS Access etc, when you try to place ActiveX control on the form or web page or create instance of the control, one or more of these methods are called to verify the licensing information from the license file (.Lic file) and upon verification the control is instantiated.
Run-Time Licensing:
Run time licensing differs for execution environments like Visual Studio or MS Access etc and Internet Explorer. In case of VS, license keys of the ActiveX controls used in the application are embedded in the executable file (.exe file) of the application whereas for Internet Explorer license keys of ActiveX control are stored in the license package file(.Lpk file).
In case of Visual Studio or MS Access, run time licensing is almost same as design time licensing. During the execution of application licensing information embedded in the exe file is verified by one or more methods of IClassFactory2 interface against the licensing information stored in the controls used in the application.
In case of Internet Explorer, licensing scenario is bit different specially when you are distributing ActiveX control (see my earlier post on How to redistribute ActiveX control with Web Application
) due to following reasons:
1.ActiveX control is executed in the remote client machine where as the host application exists in the server machine.
2.Due to the openness of the delivered HTML source code, licensing information can not be embedded in the server response.
So, due to the above scenario, run time licensing is implemented with a new file called the license package file (or LPK file). This file can be included in any HTML page by using the object tag.
Example:
< OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331" >
< PARAM NAME="LPKPath" VALUE="LPKfilename.LPK" >
< /OBJECT >
Note- CLASSID is the class ID of ActiveX License Manager component.
The above mentioned object tag embeds ActiveX License Manager, which is a component of Internet Explorer 4.0 found in the Licmgr10.dll file. This component parses an .lpk file and extracts the license key for each corresponding CLSID in the file. Remember, this tag should be added before the codebase tag for the control distribution.
At run time, when Internet Explorer 4.0 is rendering an HTML page that contains ActiveX Controls, the License Manager calls the IClassFactory2::CreateInstanceLic method, passing the license key that it extracted from the .lpk file in order to verify that a control is licensed. If the license key matches the control's license, the control will be rendered on the page.
Note: - LPK file should exists at the root of the application in the hosting server. Although you can add multiple lpk files in the web page but only first one will be considered by IE. Licensing information of all the licensed controls used in a page should be added in a lpk file embedded in that page.
Create license package file (.lpk file):
LPK file can be created using a utility named License Package Authoring Tool (Lpk_Tool.exe) that can be downloaded from the download section of this blog.
The application is actually simple to use. When you start the application, it displays a combo box that lists all of the ActiveX Controls currently running on your computer. The next step requires that you choose the controls that you want to display on a given HTML page. You choose a control by highlighting it in the combo box and then clicking the Add button. Once you've selected all the controls that you want to display on a given page, you can create and save the actual .lpk file by clicking the Save & Exit button.
References:
http://msdn.microsoft.com/en-us/library/aa231198(VS.60).aspx
http://msdn.microsoft.com/en-us/library/aa751973(VS.85).aspx
~ No comments: ~
How to improve performance of Windows XP
Following are some tips to improve performance of your Windows XP OS.
1. Use Disk Defragmenter utility - One of the easiest ways to boost up XP's speed is defragmenting your hard drive regularly. You can find this utility in the System Tools section in Accessories.
2. Use Disk Cleanup utility - Disk cleaning helps you to remove unwanted files and programs from your hard disk, which helps IO operations of Win XP. It can be used to remove temporary Internet files, remove downloaded program files, empty the Recycle Bin, remove Windows temporary files, remove optional Windows components and remove installed programs that are no longer in use.
3. Stop Windows Index Service - Windows XP by default indexes files on local and network drives to speed up the file search process. However, this slows the PC performance as it indexes files continuously. So if you don't use the service regularly it is better to disable the process.
4. Remove unwanted start-up program - Having too many program in the program startup list also slows down the booting process of Win Xp. Therefore remove unwanted program from the startup list by running "msconfig" utility and unselecting programs from the startup list.
5. Remove unused fonts - Installing too many fonts in your machine also slows down Win XP. Delete unnecessary fonts from fonts folder in the control panel.
1. Use Disk Defragmenter utility - One of the easiest ways to boost up XP's speed is defragmenting your hard drive regularly. You can find this utility in the System Tools section in Accessories.
2. Use Disk Cleanup utility - Disk cleaning helps you to remove unwanted files and programs from your hard disk, which helps IO operations of Win XP. It can be used to remove temporary Internet files, remove downloaded program files, empty the Recycle Bin, remove Windows temporary files, remove optional Windows components and remove installed programs that are no longer in use.
3. Stop Windows Index Service - Windows XP by default indexes files on local and network drives to speed up the file search process. However, this slows the PC performance as it indexes files continuously. So if you don't use the service regularly it is better to disable the process.
4. Remove unwanted start-up program - Having too many program in the program startup list also slows down the booting process of Win Xp. Therefore remove unwanted program from the startup list by running "msconfig" utility and unselecting programs from the startup list.
5. Remove unused fonts - Installing too many fonts in your machine also slows down Win XP. Delete unnecessary fonts from fonts folder in the control panel.
~ No comments: ~
How to View Source HTML of Modal Dialog Window
Its a known functionality of the windows opened using ShowModalDialog function of javascript that you can not view html source of a modal dialog window but its a problem during the development because you might need to view html source of the window for debugging.
Here is the simple solution of the problem...
Add following javascript code in your web page.
< script language="javascript" >
function showHTML()
{
d=window.open();
d.document.open('text/plain').write(document.documentElement.outerHTML);
}
< /script >
And add following html code anywhere in the body of the web page.
< input type=button value="View Source" onclick="showHTML()" >
Now when you will browse your modal window and click on the said button, the HTML source code of the modal window will open in another window.
Here is the simple solution of the problem...
Add following javascript code in your web page.
< script language="javascript" >
function showHTML()
{
d=window.open();
d.document.open('text/plain').write(document.documentElement.outerHTML);
}
< /script >
And add following html code anywhere in the body of the web page.
< input type=button value="View Source" onclick="showHTML()" >
Now when you will browse your modal window and click on the said button, the HTML source code of the modal window will open in another window.
~ 3 comments: ~
Server error : "There is no web named"
Server error : "There is no web named" .If this Web site exists on the server, check to make sure the FrontPage Server Extensions are installed, and that you have permission to access the server.
Solution: There could be many reasons for this error and there are many solution/suggestions available online but in my case none of them proved helpful. I could resolve this problem just by removing the Host Header Name from my website.
Steps:-
1. Open Internet Information Services Console window.
2. Right click on the website and open the website properties.
3. Click on website tab and then click on advance button in the web Site Identification section.
4.Now from the Advanced Multiple Web Site Configuration window, you can delete the Host Header Name associate with the IP adderss or the Default value. Remember dont delete the entry itself but edit it to remove the Header Name.
Solution: There could be many reasons for this error and there are many solution/suggestions available online but in my case none of them proved helpful. I could resolve this problem just by removing the Host Header Name from my website.
Steps:-
1. Open Internet Information Services Console window.
2. Right click on the website and open the website properties.
3. Click on website tab and then click on advance button in the web Site Identification section.
4.Now from the Advanced Multiple Web Site Configuration window, you can delete the Host Header Name associate with the IP adderss or the Default value. Remember dont delete the entry itself but edit it to remove the Header Name.
~ 1 comment: ~
How to access HEAD tag from content page in asp.net
Sometimes we need to access head tag of master page from it content page for adding element tags like style, base ect. from its content page.
There could be various ways to add head tag elements from content page. Here I have mentioned how to add meta,style and base tag in the header section.
1. Adding META tags are quite easy.Add following C# code in the page load method of the content page.
HtmlMeta metatag = new HtmlMeta();
metatag.Name = "keywords";
metatag.Content = "ajax";
this.Header.Controls.Add(metatag);
2. Adding Style tag
HtmlGenericControl styles = new HtmlGenericControl("style");
styles.Attributes.Add("type", "text/css");
styles.InnerText = "a { color: #003399; text-decoration: none;}";
this.Header.Controls.Add(styles);
it will be rendered like this:-
< style type="text/css" > a {color: #003399;text-decoration: none;} < /style >
OR if you have already added style tag in it, you can access in like a variable and update it.
like:- < style type=”text/css” runat=”server” id=”myStyles” >
then in the content page it can be accessed like -
myStyles.InnerText += "a {color: #003399;text-decoration: none;}";
3. Adding Base tag - Add following C# code in the page load method of the content page.
HtmlGenericControl Tag = new HtmlGenericControl("BASE");
Tag.Attributes.Add("target", "_self");
this.Header.Controls.Add(Tag);
-----------------------------------
Another inovative way to access and update headed section is just add asp ContentPlaceHolder control in the Head section of your master page and then it can be access just like other ContentPlaceHolders with placing content tag in your content page for adding elements in the Header of the page.
like in the Master page(PopUp.master):-
< head runat="server" >
< title >< /title >
< asp:ContentPlaceHolder runat="server" id="MyHeader" >
< /asp:ContentPlaceHolder >
< /head >
In the content page-
< %@ Page Language="C#" MasterPageFile="~/Popup.master" AutoEventWireup="true" CodeFile="popUploadFile.aspx.cs"
Inherits="PopUp_popUploadFile" Title="Attachments" % >
< asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MyHeader" >
< style type="text/css" > a {color: #003399;text-decoration: none;} < /style >
< /style >
< /asp:Content >
There could be various ways to add head tag elements from content page. Here I have mentioned how to add meta,style and base tag in the header section.
1. Adding META tags are quite easy.Add following C# code in the page load method of the content page.
HtmlMeta metatag = new HtmlMeta();
metatag.Name = "keywords";
metatag.Content = "ajax";
this.Header.Controls.Add(metatag);
2. Adding Style tag
HtmlGenericControl styles = new HtmlGenericControl("style");
styles.Attributes.Add("type", "text/css");
styles.InnerText = "a { color: #003399; text-decoration: none;}";
this.Header.Controls.Add(styles);
it will be rendered like this:-
< style type="text/css" > a {color: #003399;text-decoration: none;} < /style >
OR if you have already added style tag in it, you can access in like a variable and update it.
like:- < style type=”text/css” runat=”server” id=”myStyles” >
then in the content page it can be accessed like -
myStyles.InnerText += "a {color: #003399;text-decoration: none;}";
3. Adding Base tag - Add following C# code in the page load method of the content page.
HtmlGenericControl Tag = new HtmlGenericControl("BASE");
Tag.Attributes.Add("target", "_self");
this.Header.Controls.Add(Tag);
-----------------------------------
Another inovative way to access and update headed section is just add asp ContentPlaceHolder control in the Head section of your master page and then it can be access just like other ContentPlaceHolders with placing content tag in your content page for adding elements in the Header of the page.
like in the Master page(PopUp.master):-
< head runat="server" >
< title >< /title >
< asp:ContentPlaceHolder runat="server" id="MyHeader" >
< /asp:ContentPlaceHolder >
< /head >
In the content page-
< %@ Page Language="C#" MasterPageFile="~/Popup.master" AutoEventWireup="true" CodeFile="popUploadFile.aspx.cs"
Inherits="PopUp_popUploadFile" Title="Attachments" % >
< asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MyHeader" >
< style type="text/css" > a {color: #003399;text-decoration: none;} < /style >
< /style >
< /asp:Content >
~ No comments: ~
How to redistribute ActiveX controls with Web Application
If your website using ActiveX control then it needs to be installed on the client machine to use the functionality your website is providing through this control. Generally when such functionality is browsed by the client, web browser prompts the user for the installation of ActiveX control if it does not exists on the client machine.
(note - the above discussed behavior is subjected to the web browser settings)
The standard way to redistribute ActiveX controls through web pages is to package the ActiveX control and every other required file into a CAB file. The CAB file should be published on a web site and the CODEBASE parameter of the OBJECT HTML tag must be used to specify the location from where the ActiveX control and the dependent files can be downloaded.
Example:
< object id="ctrl" width=472 height=327 classid="CLSID:19B50C95-6BB5-4DFD-B20C-5B9A61FA1C0D" CODEBASE="http://www.website.com/redistribution/ctrl.cab" >
< /object >
Microsoft IE versions 3.0 and later use the CODEBASE attribute of object HTML tag to detect which version of ActiveX Control is installed on a user's computer and download & install the newer version of ActiveX control from the location specified by CODEBASE onto the user's machine if user is using older version.
Example:
< object id="ctrl" width=472 height=327 classid="CLSID:19B50C95-6BB5-4DFD-B20C-5B9A61FA1C0D" CODEBASE="http://www.website.com/redistribution/ctrl.cab#version=9,0,115,0" >
< /object >
The numbers '9,0,115,0' specify which version of the ActiveX control is required to use web functionality it provides.
(note - the above discussed behavior is subjected to the web browser settings)
The standard way to redistribute ActiveX controls through web pages is to package the ActiveX control and every other required file into a CAB file. The CAB file should be published on a web site and the CODEBASE parameter of the OBJECT HTML tag must be used to specify the location from where the ActiveX control and the dependent files can be downloaded.
Example:
< object id="ctrl" width=472 height=327 classid="CLSID:19B50C95-6BB5-4DFD-B20C-5B9A61FA1C0D" CODEBASE="http://www.website.com/redistribution/ctrl.cab" >
< /object >
Microsoft IE versions 3.0 and later use the CODEBASE attribute of object HTML tag to detect which version of ActiveX Control is installed on a user's computer and download & install the newer version of ActiveX control from the location specified by CODEBASE onto the user's machine if user is using older version.
Example:
< object id="ctrl" width=472 height=327 classid="CLSID:19B50C95-6BB5-4DFD-B20C-5B9A61FA1C0D" CODEBASE="http://www.website.com/redistribution/ctrl.cab#version=9,0,115,0" >
< /object >
The numbers '9,0,115,0' specify which version of the ActiveX control is required to use web functionality it provides.
~ No comments: ~
URL Rewriting error : is not a valid virtual path
Sometimes this error occurs when you are doing some url rewriting with RewritePath method. One of the many possible reasons for this error is that assigning complete url path as a internal rewrite path. Therefore pass relative rewrite url path as a parameter to the RewritePath function instead of complete url.
For example, in the below given code, statement 1 will produce error where as statement 2 will work fine.
1. HttpContext.Current.RewritePath("http://localhost/TestSite/default.aspx");
2. HttpContext.Current.RewritePath("/TestSite/default.aspx");
For example, in the below given code, statement 1 will produce error where as statement 2 will work fine.
1. HttpContext.Current.RewritePath("http://localhost/TestSite/default.aspx");
2. HttpContext.Current.RewritePath("/TestSite/default.aspx");
~ 4 comments: ~
What is ASP.NET Development Server?
In VS 2005, file system websites are hosted on the new local web server called” ASP.NET Development Server” by default instead of IIS. This server dynamically chooses the port and hosts the website for local requests only. As a part of Framework 2.0 WebDev.WebServer.exe program runs as development server and host the website whenever website is run in the VS.
Now IIS does not installed along with WinXP or Win2003 like previous versions of Windows, you needs to install it separately therefore if you are developing websites using VS 2005, you don’t have to worry about the web server to host your website as asp.net development server will take care of it.
This program is found at (%WINDIR%\Microsoft.NET\Framework\v2.0.XXXXX) location.
You can also host website manually using this program.
Syntax: WebDev.WebServer.exe [/port:] /path: [/vpath:]
Like: webdev.webserver.exe /port:4955 /path:"c:\RnD\WebSite1" /vpath:”/WebSite1”
Here you can assign any port no you want.
Difference between ASP.NET Development Server and IIS Server
Below are some notable differences:
•Development server only accepts authenticated requests on the local computer as it runs under the security context of currently authenticated user account. It means it doesn’t run under less privileged ASPNET account. Where as IIS by default runs under ASPNET account.
•Unlike IIS, Development server can only serve local requests. It will not serve pages to another computer.
•Unlike IIS, Development server can only serve resources like files that are within the application scope.
•IIS provides other services like SMTP, FTP etc. that development server does not provides so if your application has e-mail sending functionality or file download functionality, you would have to use IIS server.
Reference: http://msdn.microsoft.com/en-us/library/58wxa9w5(VS.80).aspx
Now IIS does not installed along with WinXP or Win2003 like previous versions of Windows, you needs to install it separately therefore if you are developing websites using VS 2005, you don’t have to worry about the web server to host your website as asp.net development server will take care of it.
This program is found at (%WINDIR%\Microsoft.NET\Framework\v2.0.XXXXX) location.
You can also host website manually using this program.
Syntax: WebDev.WebServer.exe [/port:
Like: webdev.webserver.exe /port:4955 /path:"c:\RnD\WebSite1" /vpath:”/WebSite1”
Here you can assign any port no you want.
Difference between ASP.NET Development Server and IIS Server
Below are some notable differences:
•Development server only accepts authenticated requests on the local computer as it runs under the security context of currently authenticated user account. It means it doesn’t run under less privileged ASPNET account. Where as IIS by default runs under ASPNET account.
•Unlike IIS, Development server can only serve local requests. It will not serve pages to another computer.
•Unlike IIS, Development server can only serve resources like files that are within the application scope.
•IIS provides other services like SMTP, FTP etc. that development server does not provides so if your application has e-mail sending functionality or file download functionality, you would have to use IIS server.
Reference: http://msdn.microsoft.com/en-us/library/58wxa9w5(VS.80).aspx
~ 1 comment: ~
Website Logging and AWStats Tool
Analysis of a website is very important if you want to optimize the performance of the website. The informations like from where most of the web traffic is coming or who is eating up your sites bandwidth are very handy for improving your websites performance. These informations are logged by the web servers that can be processed by some tools like AWStats, Analog, Webalizer etc... into some graphical charts for easy analysis.
Web logging is by default enabled in IIS5.1 web server and the data is stored in the
C:\WINDOWS\system32\LogFiles\W3SVC1 location in the form of text files with the name format like exyymmdd.log, here yy- year, mm-month and dd-day.
By default some selected properties are logged so you can customize the logging information to your requirement.For that -
Open the website properties window and click on the properties button in the enable logging section. Extented logging properties window will open. Here check & uncheck the properties you want to log like you you want to measure bandwidth comsumption of your site, check Bytes Sent option or if you want to know who is sending most of the traffic , check Referer option.
AWStats Tool
This is the tool to analyse this web logging information and show it with graphics chart.This tool is free for use.
Check out below link for more information on this tool.
http://awstats.sourceforge.net/
Web logging is by default enabled in IIS5.1 web server and the data is stored in the
C:\WINDOWS\system32\LogFiles\W3SVC1 location in the form of text files with the name format like exyymmdd.log, here yy- year, mm-month and dd-day.
By default some selected properties are logged so you can customize the logging information to your requirement.For that -
Open the website properties window and click on the properties button in the enable logging section. Extented logging properties window will open. Here check & uncheck the properties you want to log like you you want to measure bandwidth comsumption of your site, check Bytes Sent option or if you want to know who is sending most of the traffic , check Referer option.
AWStats Tool
This is the tool to analyse this web logging information and show it with graphics chart.This tool is free for use.
Check out below link for more information on this tool.
http://awstats.sourceforge.net/
~ No comments: ~
Uploading Multiple Files in ASP.NET
In this post I have given code for uploading multiple files using client callback.
Here I will not explain client callback as I have published a dedicated post on it.
Now, this multiple files upload functionality has 4 parts:
1. Selecting multiple files functionality and Upload button functionality that will request the client callback in FileUpload.aspx page .
2. Implementing ICallbackHandler interface by defining GetCallbackResult and RaiseCallbackEvent methods in the FileUpload.aspx.cs file. RaiseCallbackEvent methods will call UploadFile method of WebClient class, which posts the file to the given url(in our case it is fileserver.aspx).
3. Saving functionality for uploaded file on the server in Fileserver.aspx file.
Here is the sample code.
I have not explained it in details as it is self explainatory yet I have commented code as and when required.
----------------------------------------------------------------------
File - FileUpload.aspx
< script language="javascript" type="text/javascript">
var selectedFiles = '';
function CallbackResultHandler(result, context) //this function will receive the callback result
{
alert(result);
}
// below function will receive callback resulted appended with error msg when server throws an error
function CallbackErrorHandler(result, context)
{
alert("Error: " + result);
}
function uploadFile() // this function will trigger the callback
{
var fileList = document.getElementById("divUploadFile").getElementsByTagName("INPUT");
for(i=0; i < fileList.length;i++)
{
selectedFiles += fileList[i].value + "|";
}
< %=_callbackRef % > // here callback method - WebForm_doCallback will be rendered.
}
function attachFile()
{
var varTag1 = document.createElement("INPUT");
varTag1.type = "file";
var varTag2 = document.createElement("< BR >");
document.getElementById("divUploadFile").appendChild(varTag1);
document.getElementById("divUploadFile").appendChild(varTag2);
}
< /script >
< html xmlns="http://www.w3.org/1999/xhtml">
< head runat="server">
< title >File Upload Page< /title >
< /head >
< body >
< form id="form1" runat="server" >
< div >
< table >
< tr >
< td colspan="2">
< ol >
< li style="list-style: none">
< div id="divUploadFile" / >
< /li >
< /ol >
< /td >
< /tr >
< tr >
< td >
< a href="#" onclick="attachFile()">Attach a file< /a >
< /td >
< td >
< input type="button" value="Upload" onclick="uploadFile()" / >
< /td >
< /tr >
< /table >
< /div >
< /form >
< /body >
< /html >
------------------------------------------------------------------
File - FileUpload.aspx.cs
public partial class FileUpload : System.Web.UI.Page, ICallbackEventHandler
{
string _result = string.Empty;
protected string _callbackRef = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
//following code returns the javascript call to WebForm_doCallback function
_callbackRef = ClientScript.GetCallbackEventReference(this, "selectedFiles", "CallbackResultHandler","null", "CallbackErrorHandler", true);
}
#region ICallbackEventHandler Members
public string GetCallbackResult() //returnd the callback result
{
return _result;
}
public void RaiseCallbackEvent(string eventArgument) // invokes callback event
{
string[] Files = (eventArgument.TrimEnd('|')).Split('|');
System.Net.WebClient Client = new System.Net.WebClient();
try
{
string Url = "http://localhost:" + Request.Url.Port.ToString() +
"/FileUploadWebsite/FileServer.aspx";
foreach (string file in Files)
{
Client.UploadFile(Url, "POST", file);
}
_result = "All files are uploaded successfully.";
}
catch (System.Net.WebException ex)
{
_result = "One or more file(s) could not be uploaded.";
throw ex;
}
}
#endregion
}
-------------------------------------------------------------
File - Fileserver.aspx
< script runat="server" >
void Page_Load(object sender, EventArgs e)
{
string Uploadpath = @"C:\TestWeb\UploadedFiles\"; // ASPNET account should have read/write permission on the folder
string[] Keys = Request.Files.AllKeys;
foreach (String key in Keys)
{
HttpPostedFile File = Request.Files[key];
File.SaveAs(Uploadpath + File.FileName);
}
}
< /script >
< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title >File Server Page< /title >
< /head >
< body >
< form id="form1" runat="server">
< div >
< /div >
< /form >
< /body >
< /html >
Here I will not explain client callback as I have published a dedicated post on it.
Now, this multiple files upload functionality has 4 parts:
1. Selecting multiple files functionality and Upload button functionality that will request the client callback in FileUpload.aspx page .
2. Implementing ICallbackHandler interface by defining GetCallbackResult and RaiseCallbackEvent methods in the FileUpload.aspx.cs file. RaiseCallbackEvent methods will call UploadFile method of WebClient class, which posts the file to the given url(in our case it is fileserver.aspx).
3. Saving functionality for uploaded file on the server in Fileserver.aspx file.
Here is the sample code.
I have not explained it in details as it is self explainatory yet I have commented code as and when required.
----------------------------------------------------------------------
File - FileUpload.aspx
< script language="javascript" type="text/javascript">
var selectedFiles = '';
function CallbackResultHandler(result, context) //this function will receive the callback result
{
alert(result);
}
// below function will receive callback resulted appended with error msg when server throws an error
function CallbackErrorHandler(result, context)
{
alert("Error: " + result);
}
function uploadFile() // this function will trigger the callback
{
var fileList = document.getElementById("divUploadFile").getElementsByTagName("INPUT");
for(i=0; i < fileList.length;i++)
{
selectedFiles += fileList[i].value + "|";
}
< %=_callbackRef % > // here callback method - WebForm_doCallback will be rendered.
}
function attachFile()
{
var varTag1 = document.createElement("INPUT");
varTag1.type = "file";
var varTag2 = document.createElement("< BR >");
document.getElementById("divUploadFile").appendChild(varTag1);
document.getElementById("divUploadFile").appendChild(varTag2);
}
< /script >
< html xmlns="http://www.w3.org/1999/xhtml">
< head runat="server">
< title >File Upload Page< /title >
< /head >
< body >
< form id="form1" runat="server" >
< div >
< table >
< tr >
< td colspan="2">
< ol >
< li style="list-style: none">
< div id="divUploadFile" / >
< /li >
< /ol >
< /td >
< /tr >
< tr >
< td >
< a href="#" onclick="attachFile()">Attach a file< /a >
< /td >
< td >
< input type="button" value="Upload" onclick="uploadFile()" / >
< /td >
< /tr >
< /table >
< /div >
< /form >
< /body >
< /html >
------------------------------------------------------------------
File - FileUpload.aspx.cs
public partial class FileUpload : System.Web.UI.Page, ICallbackEventHandler
{
string _result = string.Empty;
protected string _callbackRef = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
//following code returns the javascript call to WebForm_doCallback function
_callbackRef = ClientScript.GetCallbackEventReference(this, "selectedFiles", "CallbackResultHandler","null", "CallbackErrorHandler", true);
}
#region ICallbackEventHandler Members
public string GetCallbackResult() //returnd the callback result
{
return _result;
}
public void RaiseCallbackEvent(string eventArgument) // invokes callback event
{
string[] Files = (eventArgument.TrimEnd('|')).Split('|');
System.Net.WebClient Client = new System.Net.WebClient();
try
{
string Url = "http://localhost:" + Request.Url.Port.ToString() +
"/FileUploadWebsite/FileServer.aspx";
foreach (string file in Files)
{
Client.UploadFile(Url, "POST", file);
}
_result = "All files are uploaded successfully.";
}
catch (System.Net.WebException ex)
{
_result = "One or more file(s) could not be uploaded.";
throw ex;
}
}
#endregion
}
-------------------------------------------------------------
File - Fileserver.aspx
< script runat="server" >
void Page_Load(object sender, EventArgs e)
{
string Uploadpath = @"C:\TestWeb\UploadedFiles\"; // ASPNET account should have read/write permission on the folder
string[] Keys = Request.Files.AllKeys;
foreach (String key in Keys)
{
HttpPostedFile File = Request.Files[key];
File.SaveAs(Uploadpath + File.FileName);
}
}
< /script >
< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title >File Server Page< /title >
< /head >
< body >
< form id="form1" runat="server">
< div >
< /div >
< /form >
< /body >
< /html >
~ 2 comments: ~
Script Callback in ASP.NET
In very simple term script callback is a machanims of calling server side code from client side(using javascript) without rendering the web page. In other term posting web page asynchronously. In the heart of it, is XmlHttpRequest DOM object. During a normal page postback(synchronous), the Web page and controls are recreated and a new version of the entire Web page is rendered on the client. Where as in the client callback browser create new connection using XmlHttpRequest to send only the callback data to the remote server not the content of entire page making the page lifecycle short(page rendering event does not occur).
The ASP.NET 2.0 implementation of client callbacks uses the Client Callback Manager. After initial page load, subsequent requests to server-side code are made by a client-side component, without refreshing the entire Web page. The page runs a modified version of its normal life cycle where the page is initiated and loaded, but the page contents are not rendered. Instead, a special method in the server-side code is invoked, which processes the callback request content, then returns a value to the browser that can be read by JavaScript function. The JavaScript function uses technology inherent to the browser (e.g. DOM, DHTML) to update Web page content dynamically. The Web page continues to stay live while the request is being processed.
The Page.IsPostback property will return true for both request types(normal postback & client callback). The Page. But IsCallback property will return true only when the request is a client callback.
Page LifeCycle in case of Client Callback:
Init-> LoadState-> ProcessPostbackData-> Load-> ChangeEvent-> RaiseCallbackEvent-> GetCallbackResult -> Unload
Note-: PostBack , PreRender, Render and SaveState events are skiped.
Implementing Client Callback:
Following are the steps:-
1. Write a javascript function that will request the callback by calling WebForm_DoCallback function.
2. Write another javascript function(Callbackhandler) that will receive the callback and do the needful client side processing.
3. Call the GetCallbackEventReference method in the Page_Load event.
This method creates a JavaScript string containing code for calling WebForm_DoCallback function in the client Web page to start the callback.
like :WebForm_DoCallback('__Page', message, processMyResult, context, postMyError, true)
Syntax: GetCallbackEventReference(control, argument, clientCallback, context, clientErrorCallback, useAsync);
control - The control or the page which implements ICallbackEventHandler.
argument - data that needs to be processed by the asynchronous call.
clientCallback - javascript function(Callbackhandler) that will receive the result.
context - Name of a client-side JavaScript variable. Usually used to determine the content of the message (argument) in the callback request. The value of the variable will be stored on the client as the context parameter associated with a callback.
clientErrorCallback - javascript function that will receive the result when server throws an error.
useAsync - boolean value to determine if the call is async or not.
4. Implement the System.Web.UI.ICallbackEventHandler interface by defining its 2 methods- RaiseCallbackEvent and GetCallbackResult.
Here is the code sample:
File - syncCallback.aspx
< script language="javascript">
function CallbackHandler(result, context) //Step 2
{
alert(result);
}
< /script >
< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title >Client Callback Demo< /title >
< /head >
< body >
< form id="form1" runat="server" >
< div >
Name :< input id="txtName" type="text" />
< input id="btnClient" type="button" value="Asyn Callback" runat="server" / >
< /div >
< /form >
< /body >
< /html >
File - syncCallback.aspx.cs
public partial class syncCallback : System.Web.UI.Page, ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
string CallbackRef = ClientScript.GetCallbackEventReference(this,"document.all['txtName'].value","CallbackHandler", "null",true);
//Step 3 will generate following string
// WebForm_DoCallback('__Page',document.all['txtName'].value,CallbackHandler,null,null,true)
btnClient.Attributes["onclick"] = String.Format("javascript:{0}",CallbackRef); //Step 1
}
#region ICallbackEventHandler Members
string _str;
public string GetCallbackResult() //Step 4
{
return _str;
}
public void RaiseCallbackEvent(string eventArgument) //Step 4
{
_str = "Hello " + eventArgument;
}
#endregion
}
The ASP.NET 2.0 implementation of client callbacks uses the Client Callback Manager. After initial page load, subsequent requests to server-side code are made by a client-side component, without refreshing the entire Web page. The page runs a modified version of its normal life cycle where the page is initiated and loaded, but the page contents are not rendered. Instead, a special method in the server-side code is invoked, which processes the callback request content, then returns a value to the browser that can be read by JavaScript function. The JavaScript function uses technology inherent to the browser (e.g. DOM, DHTML) to update Web page content dynamically. The Web page continues to stay live while the request is being processed.
The Page.IsPostback property will return true for both request types(normal postback & client callback). The Page. But IsCallback property will return true only when the request is a client callback.
Page LifeCycle in case of Client Callback:
Init-> LoadState-> ProcessPostbackData-> Load-> ChangeEvent-> RaiseCallbackEvent-> GetCallbackResult -> Unload
Note-: PostBack , PreRender, Render and SaveState events are skiped.
Implementing Client Callback:
Following are the steps:-
1. Write a javascript function that will request the callback by calling WebForm_DoCallback function.
2. Write another javascript function(Callbackhandler) that will receive the callback and do the needful client side processing.
3. Call the GetCallbackEventReference method in the Page_Load event.
This method creates a JavaScript string containing code for calling WebForm_DoCallback function in the client Web page to start the callback.
like :WebForm_DoCallback('__Page', message, processMyResult, context, postMyError, true)
Syntax: GetCallbackEventReference(control, argument, clientCallback, context, clientErrorCallback, useAsync);
control - The control or the page which implements ICallbackEventHandler.
argument - data that needs to be processed by the asynchronous call.
clientCallback - javascript function(Callbackhandler) that will receive the result.
context - Name of a client-side JavaScript variable. Usually used to determine the content of the message (argument) in the callback request. The value of the variable will be stored on the client as the context parameter associated with a callback.
clientErrorCallback - javascript function that will receive the result when server throws an error.
useAsync - boolean value to determine if the call is async or not.
4. Implement the System.Web.UI.ICallbackEventHandler interface by defining its 2 methods- RaiseCallbackEvent and GetCallbackResult.
Here is the code sample:
File - syncCallback.aspx
< script language="javascript">
function CallbackHandler(result, context) //Step 2
{
alert(result);
}
< /script >
< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title >Client Callback Demo< /title >
< /head >
< body >
< form id="form1" runat="server" >
< div >
Name :< input id="txtName" type="text" />
< input id="btnClient" type="button" value="Asyn Callback" runat="server" / >
< /div >
< /form >
< /body >
< /html >
File - syncCallback.aspx.cs
public partial class syncCallback : System.Web.UI.Page, ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
string CallbackRef = ClientScript.GetCallbackEventReference(this,"document.all['txtName'].value","CallbackHandler", "null",true);
//Step 3 will generate following string
// WebForm_DoCallback('__Page',document.all['txtName'].value,CallbackHandler,null,null,true)
btnClient.Attributes["onclick"] = String.Format("javascript:{0}",CallbackRef); //Step 1
}
#region ICallbackEventHandler Members
string _str;
public string GetCallbackResult() //Step 4
{
return _str;
}
public void RaiseCallbackEvent(string eventArgument) //Step 4
{
_str = "Hello " + eventArgument;
}
#endregion
}
~ 2 comments: ~
Error: Automation server can'nt create object
If you are getting error "Automation server can'nt create object" while creating activeX object.like:
var shell = new ActiveXObject("wscript.shell");
It could be due to security settings of your web browser. So to fix this error choose Internet Options from Tools menue and go to Security tab, now choose internet zone and click on Custom level...button. Now, in the security settings window go to "ActiveX controls and Plug-ins" section and enable "Initialize and script ActiveX controls not marked as safe for scripting" and "Run ActiveX controls and plug-ins" options. Enable same options for Local intranet zone also.
Now you should be able to create wscript.shell object.
var shell = new ActiveXObject("wscript.shell");
It could be due to security settings of your web browser. So to fix this error choose Internet Options from Tools menue and go to Security tab, now choose internet zone and click on Custom level...button. Now, in the security settings window go to "ActiveX controls and Plug-ins" section and enable "Initialize and script ActiveX controls not marked as safe for scripting" and "Run ActiveX controls and plug-ins" options. Enable same options for Local intranet zone also.
Now you should be able to create wscript.shell object.
~ 2 comments: ~
How to create ASPNET Account
The aspnet_wp or ASP.NET Machine Account(ASPNET) is created when the Microsoft .Net Framework 1.1 is installed onto a Windows XP computer. And a registry key is created at following location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList
You can aslo create it manually by creating a new key of DWORD called ASPNET and give it value 0 type Hexadec. under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\SpecialAccounts\UserList.
It can also be created by issuing the following command from the run dialog (changing the framework version number as appropriate):
%systemroot%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
Although you can delete this account but than your asp.net applications may not function properly.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList
You can aslo create it manually by creating a new key of DWORD called ASPNET and give it value 0 type Hexadec. under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\SpecialAccounts\UserList.
It can also be created by issuing the following command from the run dialog (changing the framework version number as appropriate):
%systemroot%\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe -i
Although you can delete this account but than your asp.net applications may not function properly.
~ 6 comments: ~
Error : Could not load file or assembly or one of its dependencies. Access is denied.
In case of web application if this error occurs, it means ASPNET account(for WindowsXP machine) or NETWORK SERVICE account (for Vista and Windows 2003 machine), does not have reqiured permissions(read/write) on the "%systemroot%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" folder.These are less privileged accounts used by web server to process the web request.
Actually aspnet_wp.exe worker process in IIS5 runs under ASPNET account to provide security against potential hacking.
It is shown in the user account list also whereas NETWORK SERVICE does not show up in it but rather is shown in the Security tab of the resources (like a folder) as a User Name like ASPNET that can be assigned permissoins. For that you need to do following steps:
1. right click on the folder, then
2. click on "Sharing and Security", then
3. click on "Security"
4. click on the "Add" button
5. click on "Advanced"
6. click on "Find Now"
7. Scroll down until you find "NETWORK SERVICE"
So follow above given steps go give permission(read/write) to ASPNET or NETWORK SERVICE account depending upon your OS on "%systemroot%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" folder.
Actually aspnet_wp.exe worker process in IIS5 runs under ASPNET account to provide security against potential hacking.
It is shown in the user account list also whereas NETWORK SERVICE does not show up in it but rather is shown in the Security tab of the resources (like a folder) as a User Name like ASPNET that can be assigned permissoins. For that you need to do following steps:
1. right click on the folder, then
2. click on "Sharing and Security", then
3. click on "Security"
4. click on the "Add" button
5. click on "Advanced"
6. click on "Find Now"
7. Scroll down until you find "NETWORK SERVICE"
So follow above given steps go give permission(read/write) to ASPNET or NETWORK SERVICE account depending upon your OS on "%systemroot%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files" folder.
~ No comments: ~
Error: "Access is Denied" during USB Driver Installation
First of all, make sure you are logged in with administrator account and have full permission on your machine. If you are still facing same problem then most probably the USBSTOR registry key has denied access to SYSTEM account.
So to give permission to USBSTOR registery key, open the regisrty editor and go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR
now right click on USBSTOR and choose permission from the shortcut menu, now check the SYSTEM account from the list for full permission also make sure that your user account has full permission, uncheck the deny checkbox if any and apply the changes.
Now you should be able to install the USB mass storage device driver.
So to give permission to USBSTOR registery key, open the regisrty editor and go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR
now right click on USBSTOR and choose permission from the shortcut menu, now check the SYSTEM account from the list for full permission also make sure that your user account has full permission, uncheck the deny checkbox if any and apply the changes.
Now you should be able to install the USB mass storage device driver.
~ 13 comments: ~
$get & $find functions in Javascript
These functions are defined in the ASP.NET AJAX client side library, there for you can use them only if you have included ScriptManager control of the ASP.NET AJAX.
$get - This function is equivelant of "document.getElementById" and "element.getElementById" functions. It points to "Sys.UI.DomElement.getElementById" JavaScript function which is defined as part of the ASP.NET AJAX client side library.
Syntax - var obj = $get(id,element);
element - optional (parent element to search, default is document element)
$find - Used to find component by its id. Generally used for fetching behavior of extender control.
Syntax - var obj = $find(id,parent)
parent - optional (parent element to search)
Reference - http://mattberseth.com/blog/2007/08/the_everuseful_get_and_find_as.html
$get - This function is equivelant of "document.getElementById" and "element.getElementById" functions. It points to "Sys.UI.DomElement.getElementById" JavaScript function which is defined as part of the ASP.NET AJAX client side library.
Syntax - var obj = $get(id,element);
element - optional (parent element to search, default is document element)
$find - Used to find component by its id. Generally used for fetching behavior of extender control.
Syntax - var obj = $find(id,parent)
parent - optional (parent element to search)
Reference - http://mattberseth.com/blog/2007/08/the_everuseful_get_and_find_as.html
~ 1 comment: ~
How can I stop and start window services from the command line?
Following commands can be used for start/sopt/list services from the command line
on Windows 2000/XP.
1. net start - list all running services
2. net stop - list all stopped services
3. net start "service name" - to start the service
4. net stop "service name" - to stop the service
5. sclist /R - list all running services on Windowa NT
6. sclist /S - list all stopped services on Windowa NT
7. NETSVC \\< servername > < command > < servicename > - for manage service remotely
< command > :
/list Lists installed services. Omit servicename with this command.
/query Query the status of a service.
/start Start the specified service.
/stop Stop the specified service.
/pause Pause the specified service.
/continue Restart a paused service.
on Windows 2000/XP.
1. net start - list all running services
2. net stop - list all stopped services
3. net start "service name" - to start the service
4. net stop "service name" - to stop the service
5. sclist /R - list all running services on Windowa NT
6. sclist /S - list all stopped services on Windowa NT
7. NETSVC \\< servername > < command > < servicename > - for manage service remotely
< command > :
/list Lists installed services. Omit servicename with this command.
/query Query the status of a service.
/start Start the specified service.
/stop Stop the specified service.
/pause Pause the specified service.
/continue Restart a paused service.
~ No comments: ~
ACA.NET
Avanade Connected Architectures for .NET (or ACA.NET) – is set of tools that complement Visual Studio .NET by providing a framework upon which developers can more quickly build XML-based Web services and applications. Built entirely on the Microsoft .NET platform, ACA.NET is a set of pre-configured software development components and features including database portability, robust event logging, and integrated security management. ACA.NET also provides a powerful event-driven development model to create applications with true separation of business and presentation logic enabling companies to easily support many different platforms.
All of these features are coordinated through a utility called the ACA.NET Configuration Manager tool integrated in Microsoft® Visual Studio.NET. Architects use the tool to graphically depict the application process model and generate the code that defines the structure of the application. Developers add application business logic to the generated code using the ACA.NET components and on-line help embedded in Microsoft® Visual Studio.NET.
All of these features are coordinated through a utility called the ACA.NET Configuration Manager tool integrated in Microsoft® Visual Studio.NET. Architects use the tool to graphically depict the application process model and generate the code that defines the structure of the application. Developers add application business logic to the generated code using the ACA.NET components and on-line help embedded in Microsoft® Visual Studio.NET.
~ No comments: ~
What is Citrix server?
Citrix MetaFrame Presentation Server is a technology that can allow remote users to connect to applications that are actually installed on a remote computer. It uses a mix of technology that results in that remote application looking and behaving just as though it was installed on the local machine.
It’s a server solution that uses Microsoft Terminal Services software to deliver Windows applications to PCs, Apple Macintosh computers, X terminals and UNIX workstations. This enables users of those systems to access and use those programs which are available to those using the Windows operating system. Citrix servers use two technologies; WinFrame and Independent Computing Architecture (ICA).
ICA
Short for Independent Computing Architecture, ICA is a protocol designed specifically for transmitting Windows graphical display data as well as keyboard and mouse input over a network. ICA is one of two technologies used by Citrix servers, the other being WinFrame.
WinFrame
A technology developed by Citrix Systems that turns Windows NT into a multi-user operating system. Together with another Citrix technology called ICA, WinFrame enables a Windows NT server to function like a minicomputer. The result is that network users on non-Windows machines (e.g., Macintoshes, DOS systems, and UNIX machines) can run Windows applications. The actual applications are executed on the WinFrame Application Server; the client machines are just terminals, used only for entering user input and displaying application output.
The ICA protocol is responsible for sending input and output between the client machines and the WinFrame server. Conceptually, the protocol is similar to X-Window, which serves the same purpose for UNIX systems.
It’s a server solution that uses Microsoft Terminal Services software to deliver Windows applications to PCs, Apple Macintosh computers, X terminals and UNIX workstations. This enables users of those systems to access and use those programs which are available to those using the Windows operating system. Citrix servers use two technologies; WinFrame and Independent Computing Architecture (ICA).
ICA
Short for Independent Computing Architecture, ICA is a protocol designed specifically for transmitting Windows graphical display data as well as keyboard and mouse input over a network. ICA is one of two technologies used by Citrix servers, the other being WinFrame.
WinFrame
A technology developed by Citrix Systems that turns Windows NT into a multi-user operating system. Together with another Citrix technology called ICA, WinFrame enables a Windows NT server to function like a minicomputer. The result is that network users on non-Windows machines (e.g., Macintoshes, DOS systems, and UNIX machines) can run Windows applications. The actual applications are executed on the WinFrame Application Server; the client machines are just terminals, used only for entering user input and displaying application output.
The ICA protocol is responsible for sending input and output between the client machines and the WinFrame server. Conceptually, the protocol is similar to X-Window, which serves the same purpose for UNIX systems.
~ 1 comment: ~
How to create web project in VS 2005
Unlike web project in VS 2003, website model of VS 2005 does not generate single assembily therefore migrating a web application developed in VS 2003 into website in VS 2005 creates challenge for the developers and some times does not fit into the existing requirement. So after getting feedback from the developer community around the world Microsoft introduced an add-in called "Visual Studio 2005 Web Application Projects" to overcome this problem.
Visual Studio 2005 Web Application Projects adds new project template called "web" under the project types in the New Project window. Now you can use this web project to create or migrate web application developed using VS 2003 in the VS 2005.
The add-in is available in the download section of my blog.
Note:- Before installing this add-in you need to install a patch called "Microsoft Visual Studio 2005 – Update to Support Web Application Projects" that is also available in the download section.
for more information click here.
Visual Studio 2005 Web Application Projects adds new project template called "web" under the project types in the New Project window. Now you can use this web project to create or migrate web application developed using VS 2003 in the VS 2005.
The add-in is available in the download section of my blog.
Note:- Before installing this add-in you need to install a patch called "Microsoft Visual Studio 2005 – Update to Support Web Application Projects" that is also available in the download section.
for more information click here.
~ No comments: ~
Configuring Linked Servers in SQL Server
In the sql server to run distributed query, you have to configure linked server.
Basically linked server configuration allows Sql Sevrer to execute commands against OLE DB data sources on different servers. Through linked server you can access Remote server,issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.The ability to query diverse data sources similarly.
You can create or delete a linked server definition with stored procedures or through SQL Server Enterprise Manager.
Using SQL Server Enterprise Manager:
Open SQL Server Enterprise Manager application, expand the object tree under the connected sql server for that linked server is created, expand the Server Object nod and than right click on Linked Server nod and choose new linked server option from the shortcut menu and follow the steps.
Using SPs: following list of Sps are used for managing linked servers.
1. sp_linkedservers - Shows information of all the linked servers.
2. sp_addlinkedserver - used for creating linked server.
Like:
USE master;
GO
EXEC sp_addlinkedserver
'Server Name',
N'SQL Server'
GO
3. sp_addlinkedsrvlogin - Creates or updates a mapping between logins on the local instance of SQL Server and remote logins on the linked server.
LIke:
EXEC sp_addlinkedsrvlogin 'AccountsServer', 'false', 'Domain\username', 'Username', 'password'
Let me give you complete example:
Suppose I want to connect to a database 'RnD' on the sql server 'HEX_SANJAY\HEXSANJAY' with the username 'sa' and password 'kkak'.
Execute the following code with your values for all the above mentioned settings to setup linked server.
USE [master]
GO
EXEC master.dbo.sp_addlinkedserver @server = N'HEXSANJAY',
@srvproduct=N'SQL',
@provider=N'SQLNCLI',
@datasrc=N'HEX_SANJAY\HEXSANJAY',
@catalog=N'RnD'
GO
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'HEXSANJAY',
@locallogin = NULL ,
@useself = N'False',
@rmtuser = N'sa',
@rmtpassword = N'kkak'
GO
EXEC master.dbo.sp_serveroption @server=N'HEXSANJAY', @optname=N'rpc', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'HEXSANJAY', @optname=N'rpc out', @optvalue=N'true'
GO
4. sp_dropserver - Removes a server from the list of known remote and linked servers on the local instance of SQL Server.
Like : sp_dropserver 'ACCOUNTSSERVER', 'droplogins';
Basically linked server configuration allows Sql Sevrer to execute commands against OLE DB data sources on different servers. Through linked server you can access Remote server,issue distributed queries, updates, commands, and transactions on heterogeneous data sources across the enterprise.The ability to query diverse data sources similarly.
You can create or delete a linked server definition with stored procedures or through SQL Server Enterprise Manager.
Using SQL Server Enterprise Manager:
Open SQL Server Enterprise Manager application, expand the object tree under the connected sql server for that linked server is created, expand the Server Object nod and than right click on Linked Server nod and choose new linked server option from the shortcut menu and follow the steps.
Using SPs: following list of Sps are used for managing linked servers.
1. sp_linkedservers - Shows information of all the linked servers.
2. sp_addlinkedserver - used for creating linked server.
Like:
USE master;
GO
EXEC sp_addlinkedserver
'Server Name',
N'SQL Server'
GO
3. sp_addlinkedsrvlogin - Creates or updates a mapping between logins on the local instance of SQL Server and remote logins on the linked server.
LIke:
EXEC sp_addlinkedsrvlogin 'AccountsServer', 'false', 'Domain\username', 'Username', 'password'
Let me give you complete example:
Suppose I want to connect to a database 'RnD' on the sql server 'HEX_SANJAY\HEXSANJAY' with the username 'sa' and password 'kkak'.
Execute the following code with your values for all the above mentioned settings to setup linked server.
USE [master]
GO
EXEC master.dbo.sp_addlinkedserver @server = N'HEXSANJAY',
@srvproduct=N'SQL',
@provider=N'SQLNCLI',
@datasrc=N'HEX_SANJAY\HEXSANJAY',
@catalog=N'RnD'
GO
EXEC master.dbo.sp_addlinkedsrvlogin @rmtsrvname = N'HEXSANJAY',
@locallogin = NULL ,
@useself = N'False',
@rmtuser = N'sa',
@rmtpassword = N'kkak'
GO
EXEC master.dbo.sp_serveroption @server=N'HEXSANJAY', @optname=N'rpc', @optvalue=N'true'
GO
EXEC master.dbo.sp_serveroption @server=N'HEXSANJAY', @optname=N'rpc out', @optvalue=N'true'
GO
4. sp_dropserver - Removes a server from the list of known remote and linked servers on the local instance of SQL Server.
Like : sp_dropserver 'ACCOUNTSSERVER', 'droplogins';
~ 1 comment: ~
An error has occurred while establishing a connection to the server.
Lots of people come across with the following error:
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
The reason for this error is that by default SQL Server allows only local client connection. So to enable it for remote connection you can use SQL Server 2005 Surface Area Configuration application.
Here are the steps:
1. Open SQL Server 2005 Surface Area Configuration.
2. Click on Surface Area Configuration for Services and Connections link.
3. Expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.
You will get a message, click on ok and restart the Database Engin service.
Thats it....
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.".
The reason for this error is that by default SQL Server allows only local client connection. So to enable it for remote connection you can use SQL Server 2005 Surface Area Configuration application.
Here are the steps:
1. Open SQL Server 2005 Surface Area Configuration.
2. Click on Surface Area Configuration for Services and Connections link.
3. Expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.
You will get a message, click on ok and restart the Database Engin service.
Thats it....
~ No comments: ~
Custom Paging in SQL Server
Brfore discussing custom paging, lets discusse how default paging works. Data controls like gridview are used to display data. When data is large you want to show it in parts that is possible using pagination feature of gridview. Actually gridview merely shows data, its the datasource attached to the gridview that fetchs data from the database.Now with the default paging, datasource of the gridview retrives whole data from the database and then gridview shows only the selective data from whole set of data based on the page index that user has choosen.
So, in the default paging, although you see subset of data but actually whole set of data is retrived from the DB that makes this approach preformance regressive.
Now, what is custom paging?
Through custom paging only selective set of data is retirved from the database unlike default paging. To achieve this, SQl Server 2005 has introduce a feature called ROW_NUMBER() that can be used in a query to retrive selective data from the database.
Following code example will show how to use ROW_NUMBER() in an SP that will get selective records from DB based on page index to be shown and no. of record per page parameters passed to it.
-- Create table
create table [dbo].[NUM]
(
[n] [int] NOT NULL,
[s] [varchar](128) NULL
)
GO
--Now insert 1000 records in the table.
set nocount on
declare @n int,@v int
set @n=0
while @n<1000
begin
set @v=(cast((rand()*100)as int)%100) + @n
insert into NUM
select @v,'Value: '+convert(varchar,@v)
set @n=@n+1
end
GO
-- Create stored procedure for retrieving records using sql server custom paging feature
create proc GetDataByCustomPaging
@pageindex int,
@pagesize int
as
begin
select n,s from (select ROW_NUMBER() over (order by n) as RowNum ,n,s from NUM) as tblNUM
where RowNum between (@pageindex-1)*@pagesize+1 and @pageindex*@pagesize
end
-- Execute Sp by passing page index and the size of page
exec GetDataByCustomPaging 2,10
Gridview control also supports custom paging but you need to do some coding to implement it in gridview.
So, in the default paging, although you see subset of data but actually whole set of data is retrived from the DB that makes this approach preformance regressive.
Now, what is custom paging?
Through custom paging only selective set of data is retirved from the database unlike default paging. To achieve this, SQl Server 2005 has introduce a feature called ROW_NUMBER() that can be used in a query to retrive selective data from the database.
Following code example will show how to use ROW_NUMBER() in an SP that will get selective records from DB based on page index to be shown and no. of record per page parameters passed to it.
-- Create table
create table [dbo].[NUM]
(
[n] [int] NOT NULL,
[s] [varchar](128) NULL
)
GO
--Now insert 1000 records in the table.
set nocount on
declare @n int,@v int
set @n=0
while @n<1000
begin
set @v=(cast((rand()*100)as int)%100) + @n
insert into NUM
select @v,'Value: '+convert(varchar,@v)
set @n=@n+1
end
GO
-- Create stored procedure for retrieving records using sql server custom paging feature
create proc GetDataByCustomPaging
@pageindex int,
@pagesize int
as
begin
select n,s from (select ROW_NUMBER() over (order by n) as RowNum ,n,s from NUM) as tblNUM
where RowNum between (@pageindex-1)*@pagesize+1 and @pageindex*@pagesize
end
-- Execute Sp by passing page index and the size of page
exec GetDataByCustomPaging 2,10
Gridview control also supports custom paging but you need to do some coding to implement it in gridview.
~ 1 comment: ~
Pointers in c#
Sometimes people get confused when they are asked "Can we use pointers in C#?", they retorthow it can be? C# is a managed language and we can only write managed code in C# whereas pointers are unmanaged. But they are wrong... you can use pointers in C# with some extra care.
Let me first clear what is managed and unmanaged code?
Managed code is executed under the control of Common Language Runtime (CRL) and takes advantage of services provided by CLR like garbage collection(Automatic memory allocation and de-allocation), code level security,CLS etc. Whereas unmanaged code does not execute under full control of CLR so it can create some problem therefore its also called unsafe.
But CLR allows programmer to write unmanaged code along with managed code using a keyword "unsafe".you can use this keyword for any class, method or code block that contains unmanaged code.Like...
unsafe class Class1 {}
static unsafe void Method1( int* ptr, int len{...}
unsafe
{
int* ptr;
int i = 1;
ptr = &i;
System.Console.WriteLine("Value of i is: " + *ptr);
}
To compile unmanaged code along with managed code you have to set "allow unsafe code" option in the build tab of the project properties window as true.
One more thing to remember when using pointers...
Because GC cleans up memory automatically, it can change the location of an object in the memory during cleaning. If that happens it may be the chance that your pointer will point to wrong location in the memory. This scenario is very difficult to debug as your program will compile sucessfully but will not give desired result.
So, to avoid such situation C# provide a keyword "Fixed" that informs CLR not to change the location of an object referenced by the pointer. Like...
// col is a managed variable.
Colour col = new Colour();
// use fixed to get address of col.R in the pointer
fixed ( int* ptr = &col.R)
{
*ptr = 255;
}
Let me first clear what is managed and unmanaged code?
Managed code is executed under the control of Common Language Runtime (CRL) and takes advantage of services provided by CLR like garbage collection(Automatic memory allocation and de-allocation), code level security,CLS etc. Whereas unmanaged code does not execute under full control of CLR so it can create some problem therefore its also called unsafe.
But CLR allows programmer to write unmanaged code along with managed code using a keyword "unsafe".you can use this keyword for any class, method or code block that contains unmanaged code.Like...
unsafe class Class1 {}
static unsafe void Method1( int* ptr, int len{...}
unsafe
{
int* ptr;
int i = 1;
ptr = &i;
System.Console.WriteLine("Value of i is: " + *ptr);
}
To compile unmanaged code along with managed code you have to set "allow unsafe code" option in the build tab of the project properties window as true.
One more thing to remember when using pointers...
Because GC cleans up memory automatically, it can change the location of an object in the memory during cleaning. If that happens it may be the chance that your pointer will point to wrong location in the memory. This scenario is very difficult to debug as your program will compile sucessfully but will not give desired result.
So, to avoid such situation C# provide a keyword "Fixed" that informs CLR not to change the location of an object referenced by the pointer. Like...
// col is a managed variable.
Colour col = new Colour();
// use fixed to get address of col.R in the pointer
fixed ( int* ptr = &col.R)
{
*ptr = 255;
}
~ No comments: ~
Web Page Life Cycle
Here I am not going to explain web request process but will just give you the sequence of occurance of a web page events.
Below is the sequence of web page events:
Page Initialization
Load ViewState
Load Post Data
Page Load
Raised Postback Changed Event
Raised Postback
Page PreRender
Save ViewState
Page Render
Page Unload
Now, lets take a scenario, there is a web page built upon a master page and contains a web usercontrol that has child web usercontrol in it.
Here is the sequence of events post execution of HttpModules:
Initialization
Page- PreInit
Init - ChildUserControl
Init - UserControl
Init - MasterPage
Init - Page
Page- InitComplete
Page- PreLoad
Load- Page
Load- MasterPage
Load- UserControl
Load- ChildUserControl
PostBack Event
DataBinding- Page
DataBinding- MasterPage
DataBinding- UserControl
DataBinding- ChildUserControl
Page- LoadComplete
PreRender- Page
PreRender- MasterPage
PreRender- UserControl
PreRender- ChildUserControl
Page- PreRenderComplete
Page- SaveViewStateComplete
Unload- ChildUserControl
Unload- - UserControl
Unload- - MasterPage
Unload- - Page
Below is the sequence of web page events:
Page Initialization
Load ViewState
Load Post Data
Page Load
Raised Postback Changed Event
Raised Postback
Page PreRender
Save ViewState
Page Render
Page Unload
Now, lets take a scenario, there is a web page built upon a master page and contains a web usercontrol that has child web usercontrol in it.
Here is the sequence of events post execution of HttpModules:
Initialization
Page- PreInit
Init - ChildUserControl
Init - UserControl
Init - MasterPage
Init - Page
Page- InitComplete
Page- PreLoad
Load- Page
Load- MasterPage
Load- UserControl
Load- ChildUserControl
PostBack Event
DataBinding- Page
DataBinding- MasterPage
DataBinding- UserControl
DataBinding- ChildUserControl
Page- LoadComplete
PreRender- Page
PreRender- MasterPage
PreRender- UserControl
PreRender- ChildUserControl
Page- PreRenderComplete
Page- SaveViewStateComplete
Unload- ChildUserControl
Unload- - UserControl
Unload- - MasterPage
Unload- - Page
~ No comments: ~
Difference between Temp tables and Table variables in Sql Server
Following are the difference between Temp tables and Table variables:
1. Transaction log are not recorded for table variables so they are transaction netrual or you can say they are out of scope of transaction mechanism. Whereas temp tables participate in transactions just like normal tables.
2. Table variables can not be altered it means no DDL action is allowed on them. Whereas temp tables can be altered.
3. Stored Procedure with a temporary table cannot be pre-compiled, while an execution plan of procedures with table variables can be statically compiled in advance. Pre-compiling a script gives a major advantage to its speed of execution. This advantage can be dramatic for long procedures, where recompilation can be too pricy.
4. Unlike temp tables, table variables memory resident but not always. Under memory pressure, the pages belonging to a table variable can be pushed out to tempdb.
5. There can be a big performance difference between using table variables and temporary tables. In most cases, temporary tables are faster than table variables. Although queries using table variables didn't generate parallel query plans on a large SMP box, similar queries using temporary tables (local or global) and running under the same circumstances did generate parallel plans.
Table variables use internal metadata in a way that prevents the engine from using a table variable within a parallel query. SQL Server maintains statistics for queries that use temporary tables but not for queries that use table variables. Without statistics, SQL Server might choose a poor processing plan for a query that contains a table variable.
No statistics is maintained on table variable which means that any changes in data impacting table variable will not cause recompilation of queries accessing table variable. Queries involving table variables don't generate parallel plans.
My Suggestions:
1. Use table variable where you want to pass table to the Sp as parameter b'coz there is no other choice.
2. Its found that table variable are slow in sql server 2005 than 2000 on similar data and circumstances, so if you have used table variables extensively in you BD and planning to migrate from sql server 2000 to 2005, make your choice carefully.
3. Table variables are OK if used in small queries and for processing small amount of data otherwise go for temp tables.
4. If your are using very complex business logic in your SP, its better using temp table than table variables.
1. Transaction log are not recorded for table variables so they are transaction netrual or you can say they are out of scope of transaction mechanism. Whereas temp tables participate in transactions just like normal tables.
2. Table variables can not be altered it means no DDL action is allowed on them. Whereas temp tables can be altered.
3. Stored Procedure with a temporary table cannot be pre-compiled, while an execution plan of procedures with table variables can be statically compiled in advance. Pre-compiling a script gives a major advantage to its speed of execution. This advantage can be dramatic for long procedures, where recompilation can be too pricy.
4. Unlike temp tables, table variables memory resident but not always. Under memory pressure, the pages belonging to a table variable can be pushed out to tempdb.
5. There can be a big performance difference between using table variables and temporary tables. In most cases, temporary tables are faster than table variables. Although queries using table variables didn't generate parallel query plans on a large SMP box, similar queries using temporary tables (local or global) and running under the same circumstances did generate parallel plans.
Table variables use internal metadata in a way that prevents the engine from using a table variable within a parallel query. SQL Server maintains statistics for queries that use temporary tables but not for queries that use table variables. Without statistics, SQL Server might choose a poor processing plan for a query that contains a table variable.
No statistics is maintained on table variable which means that any changes in data impacting table variable will not cause recompilation of queries accessing table variable. Queries involving table variables don't generate parallel plans.
My Suggestions:
1. Use table variable where you want to pass table to the Sp as parameter b'coz there is no other choice.
2. Its found that table variable are slow in sql server 2005 than 2000 on similar data and circumstances, so if you have used table variables extensively in you BD and planning to migrate from sql server 2000 to 2005, make your choice carefully.
3. Table variables are OK if used in small queries and for processing small amount of data otherwise go for temp tables.
4. If your are using very complex business logic in your SP, its better using temp table than table variables.
~ No comments: ~
Add an Icon to URL
How about giving personal feel to the url of your website by changing icon of your site url.
Wanna try it...Follow below given steps:
1. Create an icon file with the name "favicon.ico" or find and ico file in you system and rename its copy for your use. Make sure the size should be 16 X 16.
2. Now add this file in the root of your website.
3. And add following 2 lines in the head section of your website's home page but if you are using master page in your website then add these line in the master page's head section and it will be displayed for every web page of your site.
< link rel="icon" href="favicon.ico" type="image/ico" / >
< link rel="SHORTCUT ICON" href="favicon.ico" / >
Thats it...
Now open your site in new browser window and see the effect.
Wanna try it...Follow below given steps:
1. Create an icon file with the name "favicon.ico" or find and ico file in you system and rename its copy for your use. Make sure the size should be 16 X 16.
2. Now add this file in the root of your website.
3. And add following 2 lines in the head section of your website's home page but if you are using master page in your website then add these line in the master page's head section and it will be displayed for every web page of your site.
< link rel="icon" href="favicon.ico" type="image/ico" / >
< link rel="SHORTCUT ICON" href="favicon.ico" / >
Thats it...
Now open your site in new browser window and see the effect.
~ No comments: ~
What is Extranet?
A company LAN, or local area network, can house a private Internet-like environment called an intranet. The intranet is basically a set of HTML pages relating to internal company business, for employee's eyes only, and is not available to the Internet. If access to or from the Internet is provided, it will be through a firewall gateway that will require a username and password. In this case the intranet becomes an extranet. In short, an extranet is the extension of an intranet to include public access.
An extranet can allow public access to employees, customers, clients or partners. The extranet uses Internet protocols so users can navigate with a browser, but resides on the company's private server rather than on a public Internet server. Extranet access from the Internet can be controlled through various architectures that are password or username specific. In other words, areas of the extranet will be available according to password credentials. This limits users to extranet pages relevant to the business they might be conducting, while keeping other areas of the extranet private and secure.
An extranet requires security and privacy. These can include firewall server management, the issuance and use of digital certificates or similar means of user authentication, encryption of messages, and the use of virtual private networks (VPNs) that tunnel through the public network.
An extranet can allow public access to employees, customers, clients or partners. The extranet uses Internet protocols so users can navigate with a browser, but resides on the company's private server rather than on a public Internet server. Extranet access from the Internet can be controlled through various architectures that are password or username specific. In other words, areas of the extranet will be available according to password credentials. This limits users to extranet pages relevant to the business they might be conducting, while keeping other areas of the extranet private and secure.
An extranet requires security and privacy. These can include firewall server management, the issuance and use of digital certificates or similar means of user authentication, encryption of messages, and the use of virtual private networks (VPNs) that tunnel through the public network.
~ 1 comment: ~
Error: The file web.sitemap required by XmlSiteMapProvider does not exist.
This error occurs if XmlSiteMapProvider does not find web.sitemap file. By default it looks for this file in the root of the website therefore if you add web.sitemap file in your website you are likly to get this error.
So to overcome this error simple move web.sitemap file in the root of website if its not in the root. Or if you dont want to have web.sitemap file in the root of website, you can reconfigure XmlSiteMapProvider by adding it in the web.config file of your website.Like...
< siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
< providers >
< clear/ >
< add name="XmlSiteMapProvider"
type="System.Web.XmlSiteMapProvider, System.Web,Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="~/Resource/web.sitemap"
securityTrimmingEnabled="true"/ >
< /providers >
< /siteMap >
Note : You can ste new path of your we.sitemap in the siteMapFile attribute.
So to overcome this error simple move web.sitemap file in the root of website if its not in the root. Or if you dont want to have web.sitemap file in the root of website, you can reconfigure XmlSiteMapProvider by adding it in the web.config file of your website.Like...
< siteMap defaultProvider="XmlSiteMapProvider" enabled="true" >
< providers >
< clear/ >
< add name="XmlSiteMapProvider"
type="System.Web.XmlSiteMapProvider, System.Web,Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
siteMapFile="~/Resource/web.sitemap"
securityTrimmingEnabled="true"/ >
< /providers >
< /siteMap >
Note : You can ste new path of your we.sitemap in the siteMapFile attribute.
~ 4 comments: ~
Error: Failed to access IIS metabase
This is error occurs when you have installed IIS after installing Microsoft Visual Studio. So to overcome this error you can either run aspnet_regiis utility or re-install .net framework.
If you have installed IIS over .net framework 2.0 then you have to run this utility from following folder.
C:\Windows\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis -i
In some cases this error occurs user account under which web application is running does not have proper permission on the IIS metabase. In that case run following commond.
aspnet_regiis -ga
If you have installed IIS over .net framework 2.0 then you have to run this utility from following folder.
C:\Windows\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis -i
In some cases this error occurs user account under which web application is running does not have proper permission on the IIS metabase. In that case run following commond.
aspnet_regiis -ga
~ 3 comments: ~
Using JavaScript to prevent or trigger form submission when ENTER is hit on textbox
for Preventing:
Suppose there is a textbox control called txtDemo. Add below line of code in the page_load method.
txtDemo.Attributes.Add("onkeypress", "return noenter()");
< script type="text/javascript" >
function noenter() {
return !(window.event && window.event.keyCode == 13); }
< /script >
For Triggering:
Option 1:
Suppose there is a textbox control called txtDemo and a button control namely btnSubmit. Add below lines of code in the page_load method.
txtDemo.Attributes.Add("onkeypress", "return clickButton(event,'" + btnSubmit.ClientID + "')");
btnSubmit.Attributes.Add("onclick", "return validate_Data();");
< script type="text/javascript" >
function clickButton(e, buttonid)
{
var bt = document.getElementById(buttonid);
if (typeof bt == 'object')
{
if (event.keyCode == 13)
{
bt.click();
return false;
}
}
}
< /script >
Option 2:
In case of IE4+
Suppose there is a textbox control called txtDemo. Add below line of code in the page_load method.
txtDemo.Attributes.Add("onkeypress", "return entsub(this.form)");
< script type="text/javascript" >
function noenter() {
return !(window.event && window.event.keyCode == 13); }
< /script >
In Case of Netscape Navigator
txtDemo.Attributes.Add("onkeypress", "return entsub(event,this.form)");
< script type="text/javascript" >
function entsub(event,ourform) {
if (event && event.which == 13)
ourform.submit();
else
return true;}
< /script >
Suppose there is a textbox control called txtDemo. Add below line of code in the page_load method.
txtDemo.Attributes.Add("onkeypress", "return noenter()");
< script type="text/javascript" >
function noenter() {
return !(window.event && window.event.keyCode == 13); }
< /script >
For Triggering:
Option 1:
Suppose there is a textbox control called txtDemo and a button control namely btnSubmit. Add below lines of code in the page_load method.
txtDemo.Attributes.Add("onkeypress", "return clickButton(event,'" + btnSubmit.ClientID + "')");
btnSubmit.Attributes.Add("onclick", "return validate_Data();");
< script type="text/javascript" >
function clickButton(e, buttonid)
{
var bt = document.getElementById(buttonid);
if (typeof bt == 'object')
{
if (event.keyCode == 13)
{
bt.click();
return false;
}
}
}
< /script >
Option 2:
In case of IE4+
Suppose there is a textbox control called txtDemo. Add below line of code in the page_load method.
txtDemo.Attributes.Add("onkeypress", "return entsub(this.form)");
< script type="text/javascript" >
function noenter() {
return !(window.event && window.event.keyCode == 13); }
< /script >
In Case of Netscape Navigator
txtDemo.Attributes.Add("onkeypress", "return entsub(event,this.form)");
< script type="text/javascript" >
function entsub(event,ourform) {
if (event && event.which == 13)
ourform.submit();
else
return true;}
< /script >
~ No comments: ~
Pagination in Repeater control using PagedDataSource
PagedDataSource Class
Encapsulates the paging-related properties of a data-bound control (such as DataGrid, GridView, DetailsView, and FormView) that allow it to perform paging. This class cannot be inherited.
Below is the source code to demonstrate the use of PagedDataSource for implementing pagination in repeater control.
fileName : PagedDataSourceDemo.aspx
< table id="tbl1" cellspacing="0" >
< asp:Repeater ID="rptr1" runat="server" >
< ItemTemplate>
< tr >
< td " >
< asp:Label ID="lblId" runat="server" Text='<%# (Eval("ID") != null && !Eval("ID").ToString().Trim().Equals("")?Eval("ID"):"") %>'>
< /td >
< td >
< asp:Label ID="lblName" runat="server" Text='<%# (Eval("Name") != null && !Eval("Name").ToString().Trim().Equals("")?Eval("Name"):"") %>' >< /asp:Label >
< /a >
< /td >
< /tr >
< /ItemTemplate >
< /asp:Repeater >
< /table >
< table id="tbl2" cellspacing="0" >
< tr >
< td >
< asp:Repeater id="rptr2" runat="server" >
< /asp:Repeater >
< /td >
< /tr >
< /table >
< script runat="server" >
private DataTable _data = null;
private PagedDataSource _objPds;
private LinkButton _linkMore = null;
private LinkButton _linkPrevious = null;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["page"] != null && !Request.QueryString["page"].ToString().Equals(""))
{
CurrentPage = Int32.Parse(Request.QueryString["page"].ToString()) - 1;
LoadData();
}
if (Request.QueryString["action"] != null)
{
if (Request.QueryString["action"].ToString().Trim().Equals("next"))
{
CurrentPage += 1;
}
if (Request.QueryString["action"].ToString().Trim().Equals("previous"))
{
CurrentPage -= 1;
}
LoadData();
}
if (!IsPostBack)
LoadData();
}
private void LoadData()
{
_data = ((DataTable)Cache.Get("MyData"));
if (_data != null && _data.Rows.Count > 0)
{
rptr1.DataSource = CreatePaging(_data);
rptr1.DataBind();
}
}
protected PagedDataSource CreatePaging(DataTable dt)
{
CreatePagingButton(dt);
_objPds = new PagedDataSource();
_objPds.DataSource = dt.DefaultView;
_objPds.AllowPaging = true;
_objPds.PageSize = 10;
_objPds.CurrentPageIndex = CurrentPage;
if (_linkMore != null) _linkMore.Visible = !_objPds.IsLastPage;
if (_linkPrevious != null) _linkPrevious.Visible = !_objPds.IsFirstPage;
return _objPds;
}
public int CurrentPage
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void CreatePagingButton(DataTable TempTable)
{
if (TempTable != null && TempTable.Rows.Count > 10)
{
if (rptr2.HasControls())
rptr2.Controls.Clear();
_linkPrevious = new LinkButton();
_linkPrevious.ID = "lnkPrevious";
_linkPrevious.Text = "Previous";
_linkPrevious.Visible = false;
_linkPrevious.PostBackUrl = "~/PagedDataSourceDemo.aspx?action=previous";
rptr2.Controls.Add(_linkPrevious);
Label lblPrevious = new Label();
lblPrevious.ID = "lblprevious";
lblPrevious.Text = " | ";
lblPrevious.Visible = true;
rptr2.Controls.Add(lblPrevious);
int i = 0;
for (i = 0; i < TempTable.Rows.Count / 10; i++)
{
LinkButton linkButton = new LinkButton();
linkButton.ID = "Articles" + i;
linkButton.Text = (i + 1).ToString();
linkButton.Visible = true;
linkButton.PostBackUrl = "~/PagedDataSourceDemo.aspx?page=" + (i + 1);
rptr2.Controls.Add(linkButton);
Label lbl = new Label();
lbl.ID = "lbl" + i;
lbl.Text = " | ";
lbl.Visible = true;
rptr2.Controls.Add(lbl);
}
if (TempTable.Rows.Count % 10 > 0)
{
LinkButton linkButton = new LinkButton();
linkButton.ID = "Page" + i;
linkButton.Text = (i + 1).ToString();
linkButton.Visible = true;
linkButton.PostBackUrl = "~/PagedDataSourceDemo.aspxx?page=" + (i + 1);
rptr2.Controls.Add(linkButton);
Label lbl = new Label();
lbl.ID = "lbl" + i;
lbl.Text = " | ";
lbl.Visible = true;
rptr2.Controls.Add(lbl);
}
_linkMore = new LinkButton();
_linkMore.ID = "lnkMore";
_linkMore.Text = "Next";
_linkMore.Visible = true;
_linkMore.PostBackUrl = "~/PagedDataSourceDemo.aspx?action=next";
rptr2.Controls.Add(_linkMore);
}
}
< /script >
Encapsulates the paging-related properties of a data-bound control (such as DataGrid, GridView, DetailsView, and FormView) that allow it to perform paging. This class cannot be inherited.
Below is the source code to demonstrate the use of PagedDataSource for implementing pagination in repeater control.
fileName : PagedDataSourceDemo.aspx
< table id="tbl1" cellspacing="0" >
< asp:Repeater ID="rptr1" runat="server" >
< ItemTemplate>
< tr >
< td " >
< asp:Label ID="lblId" runat="server" Text='<%# (Eval("ID") != null && !Eval("ID").ToString().Trim().Equals("")?Eval("ID"):"") %>'>
< /td >
< td >
< asp:Label ID="lblName" runat="server" Text='<%# (Eval("Name") != null && !Eval("Name").ToString().Trim().Equals("")?Eval("Name"):"") %>' >< /asp:Label >
< /a >
< /td >
< /tr >
< /ItemTemplate >
< /asp:Repeater >
< /table >
< table id="tbl2" cellspacing="0" >
< tr >
< td >
< asp:Repeater id="rptr2" runat="server" >
< /asp:Repeater >
< /td >
< /tr >
< /table >
< script runat="server" >
private DataTable _data = null;
private PagedDataSource _objPds;
private LinkButton _linkMore = null;
private LinkButton _linkPrevious = null;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["page"] != null && !Request.QueryString["page"].ToString().Equals(""))
{
CurrentPage = Int32.Parse(Request.QueryString["page"].ToString()) - 1;
LoadData();
}
if (Request.QueryString["action"] != null)
{
if (Request.QueryString["action"].ToString().Trim().Equals("next"))
{
CurrentPage += 1;
}
if (Request.QueryString["action"].ToString().Trim().Equals("previous"))
{
CurrentPage -= 1;
}
LoadData();
}
if (!IsPostBack)
LoadData();
}
private void LoadData()
{
_data = ((DataTable)Cache.Get("MyData"));
if (_data != null && _data.Rows.Count > 0)
{
rptr1.DataSource = CreatePaging(_data);
rptr1.DataBind();
}
}
protected PagedDataSource CreatePaging(DataTable dt)
{
CreatePagingButton(dt);
_objPds = new PagedDataSource();
_objPds.DataSource = dt.DefaultView;
_objPds.AllowPaging = true;
_objPds.PageSize = 10;
_objPds.CurrentPageIndex = CurrentPage;
if (_linkMore != null) _linkMore.Visible = !_objPds.IsLastPage;
if (_linkPrevious != null) _linkPrevious.Visible = !_objPds.IsFirstPage;
return _objPds;
}
public int CurrentPage
{
get
{
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
protected void CreatePagingButton(DataTable TempTable)
{
if (TempTable != null && TempTable.Rows.Count > 10)
{
if (rptr2.HasControls())
rptr2.Controls.Clear();
_linkPrevious = new LinkButton();
_linkPrevious.ID = "lnkPrevious";
_linkPrevious.Text = "Previous";
_linkPrevious.Visible = false;
_linkPrevious.PostBackUrl = "~/PagedDataSourceDemo.aspx?action=previous";
rptr2.Controls.Add(_linkPrevious);
Label lblPrevious = new Label();
lblPrevious.ID = "lblprevious";
lblPrevious.Text = " | ";
lblPrevious.Visible = true;
rptr2.Controls.Add(lblPrevious);
int i = 0;
for (i = 0; i < TempTable.Rows.Count / 10; i++)
{
LinkButton linkButton = new LinkButton();
linkButton.ID = "Articles" + i;
linkButton.Text = (i + 1).ToString();
linkButton.Visible = true;
linkButton.PostBackUrl = "~/PagedDataSourceDemo.aspx?page=" + (i + 1);
rptr2.Controls.Add(linkButton);
Label lbl = new Label();
lbl.ID = "lbl" + i;
lbl.Text = " | ";
lbl.Visible = true;
rptr2.Controls.Add(lbl);
}
if (TempTable.Rows.Count % 10 > 0)
{
LinkButton linkButton = new LinkButton();
linkButton.ID = "Page" + i;
linkButton.Text = (i + 1).ToString();
linkButton.Visible = true;
linkButton.PostBackUrl = "~/PagedDataSourceDemo.aspxx?page=" + (i + 1);
rptr2.Controls.Add(linkButton);
Label lbl = new Label();
lbl.ID = "lbl" + i;
lbl.Text = " | ";
lbl.Visible = true;
rptr2.Controls.Add(lbl);
}
_linkMore = new LinkButton();
_linkMore.ID = "lnkMore";
_linkMore.Text = "Next";
_linkMore.Visible = true;
_linkMore.PostBackUrl = "~/PagedDataSourceDemo.aspx?action=next";
rptr2.Controls.Add(_linkMore);
}
}
< /script >
~ 2 comments: ~
How to use google maps
Below code for anchor tag will open the google map of the location in another window.
< a id="lnkMap" href='http://maps.google.com/maps?q=Street+City+State_Province+Zip_Postal_Code+Country' target="_blank" >Map/Directions< /a >
As the query string, you have to pass the adderss of the location seperated by '+' to the 'maps.google.com/maps' url.
< a id="lnkMap" href='http://maps.google.com/maps?q=Street+City+State_Province+Zip_Postal_Code+Country' target="_blank" >Map/Directions< /a >
As the query string, you have to pass the adderss of the location seperated by '+' to the 'maps.google.com/maps' url.
~ No comments: ~
Using Web Parts with SQL Server 2000
Many features of ASP.NET rely on intrinsic application services such as membership, roles, profiles, and personalization. The application services use providers, objects that persist application service data in long-term storage. For example, the ASP.NET personalization service uses a personalization provider to save personalized user settings on Web pages.
Each application service uses one provider to persist the service's data in a particular kind of data store. For each service, a SQL provider is included and configured as the default provider to persist the data in a Microsoft SQL Server database.
Note:
To persist ASP.NET application services data in another data store besides SQL Server (such as a Microsoft Access database, XML files, or other RDBMS systems), you must create a separate provider for each kind of data store. To create a custom provider, you can inherit from the base provider for a particular application service, and extend it to handle the data for the service in whatever type of data store you plan to use. For example, to create an Access database provider for the membership service, you could inherit from the MembershipProvider base class, and enable it to persist membership data in Access.
A configured personalization provider and database. Web Parts personalization is enabled by default, and it uses the SQL personalization provider (SqlPersonalizationProvider) with the Microsoft SQL Server Standard Edition to store personalization data. This walkthrough uses SSE and the default SQL provider. If you have SSE installed, no configuration is needed. SSE is available with Microsoft Visual Studio 2005 as an optional part of the installation, or as a free download. For details, see the Microsoft SQL Server 2005 Express Edition Web page. To use one of the full versions of SQL Server, you must install and configure an ASP.NET application services database, and configure the SQL personalization provider to connect to that database. For details, see Creating and Configuring the Application Services Database for SQL Server. You can also create and configure a custom provider to use with other, non-SQL databases or storage solutions. For details and a code example see Implementing a Membership Provider.
Reference : http://msdn2.microsoft.com/en-us/library/2fx93s7w.aspx
By default, Web Parts in ASP.NET 2.0 are configured to use the default SQL Express Personalization Provider for persisting Web Parts information. If you wish to use SQL Server 2000 together with Web Parts, you need to perform the following steps:
1. Run the aspnet_regsql.exe tool located in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\ to add the aspnetdb database into SQL Server 2000.
The aspnet_regsql utility is a mixed mode (both graphical- and command-line-based) tool that lets you configure SQL Server for use with your ASP.NET application.
You run the aspnet_regsql tool like this:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\>aspnet_regsql
If you invoke aspnet_regsql without any command options, you will see a wizard guiding you through the steps. Select the "Configure SQL Server for application services" option in the wizard window. Click Next and then specify your SQL Server 2000 name. Click Next and then Close.
2. In Web.config, add the following to change the default SQL Express Personalization Provider to the new SQL Server Personalization Provider:
Note: In the ConnectionString section user name and password can be changed accordingly.
< connectionStrings >
< add name="SQLConnString"
connectionString="Data Source=your_server_name;Initial
Catalog=aspnetdb;Integrated Security=false;uid=sa;pwd=kkak"
providerName="System.Data.SqlClient" / >
< /connectionStrings >
< system.web >
..
..
< webParts >
< personalization
defaultProvider="SqlPersonalizationProvider" >
< providers>
< add name="SqlPersonalizationProvider"
type="System.Web.UI.WebControls.
WebParts.SqlPersonalizationProvider"
connectionStringName="SQLConnString"
applicationName="/" / >
< /providers >
< authorization >
< deny users="*" verbs="enterSharedScope" / >
< allow users="*" verbs="modifyState" / >
< /authorization >
< /personalization >
< /webParts >
< /system.web >
The Web Parts information will now be stored in SQL Server 2000 rather than the ASPNETDB.MDF database.
Each application service uses one provider to persist the service's data in a particular kind of data store. For each service, a SQL provider is included and configured as the default provider to persist the data in a Microsoft SQL Server database.
Note:
To persist ASP.NET application services data in another data store besides SQL Server (such as a Microsoft Access database, XML files, or other RDBMS systems), you must create a separate provider for each kind of data store. To create a custom provider, you can inherit from the base provider for a particular application service, and extend it to handle the data for the service in whatever type of data store you plan to use. For example, to create an Access database provider for the membership service, you could inherit from the MembershipProvider base class, and enable it to persist membership data in Access.
A configured personalization provider and database. Web Parts personalization is enabled by default, and it uses the SQL personalization provider (SqlPersonalizationProvider) with the Microsoft SQL Server Standard Edition to store personalization data. This walkthrough uses SSE and the default SQL provider. If you have SSE installed, no configuration is needed. SSE is available with Microsoft Visual Studio 2005 as an optional part of the installation, or as a free download. For details, see the Microsoft SQL Server 2005 Express Edition Web page. To use one of the full versions of SQL Server, you must install and configure an ASP.NET application services database, and configure the SQL personalization provider to connect to that database. For details, see Creating and Configuring the Application Services Database for SQL Server. You can also create and configure a custom provider to use with other, non-SQL databases or storage solutions. For details and a code example see Implementing a Membership Provider.
Reference : http://msdn2.microsoft.com/en-us/library/2fx93s7w.aspx
By default, Web Parts in ASP.NET 2.0 are configured to use the default SQL Express Personalization Provider for persisting Web Parts information. If you wish to use SQL Server 2000 together with Web Parts, you need to perform the following steps:
1. Run the aspnet_regsql.exe tool located in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\ to add the aspnetdb database into SQL Server 2000.
The aspnet_regsql utility is a mixed mode (both graphical- and command-line-based) tool that lets you configure SQL Server for use with your ASP.NET application.
You run the aspnet_regsql tool like this:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\>aspnet_regsql
If you invoke aspnet_regsql without any command options, you will see a wizard guiding you through the steps. Select the "Configure SQL Server for application services" option in the wizard window. Click Next and then specify your SQL Server 2000 name. Click Next and then Close.
2. In Web.config, add the following to change the default SQL Express Personalization Provider to the new SQL Server Personalization Provider:
Note: In the ConnectionString section user name and password can be changed accordingly.
< connectionStrings >
< add name="SQLConnString"
connectionString="Data Source=your_server_name;Initial
Catalog=aspnetdb;Integrated Security=false;uid=sa;pwd=kkak"
providerName="System.Data.SqlClient" / >
< /connectionStrings >
< system.web >
..
..
< webParts >
< personalization
defaultProvider="SqlPersonalizationProvider" >
< providers>
< add name="SqlPersonalizationProvider"
type="System.Web.UI.WebControls.
WebParts.SqlPersonalizationProvider"
connectionStringName="SQLConnString"
applicationName="/" / >
< /providers >
< authorization >
< deny users="*" verbs="enterSharedScope" / >
< allow users="*" verbs="modifyState" / >
< /authorization >
< /personalization >
< /webParts >
< /system.web >
The Web Parts information will now be stored in SQL Server 2000 rather than the ASPNETDB.MDF database.