Posts

Showing posts with the label Asp.Net

Step by step migration of ASP.NET Core 2.2 to 3.1

In order to upgrade/migrate asp.net core version to 3.1 following steps to be perform.
Download and install Visual Studio 2019 version 16.4 or higher.Download and install .NET Core 3.1  https://dotnet.microsoft.com/download/dotnet-core/3.1Upgrade the projects of solution to .NET Core 3.1 , because ASP.NET Core 3.1 requires it.Update existing Nuget packages to a version compatible with ASP.NET Core 3.1 in each projectUse IHost interface from a IHostBuilder instead of building and running a IWebHost from a IWebHostBuilder in Program.cs public static IHostBuilder CreateWebHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseKestrel() .UseSerilog() .UseStartup<Startup>(); }) Change AddMvc method has been replaced by AddControllers in Startup.cs of each projects.In Startup.cs,UseMvc method to be replaced by…

Restore the lost focus of Auto post back controls in asp.net update Panel control

Problem:
We put  autopostback controls like textbox, DropDownList controls inside in update panel to reducing the flickering of the Page.but when user uses tab for entering the details  the focus of the control losts. Web site users who prefer to use keyboard need to use mouse to activate appropriate input box or press TAB multiple times.

Solution:

Step 1:

Save following in js file give any name to it (like MyUpdatePanelFocus.js)

var lastFocusedControlId = ""; function focusHandler(e) { document.activeElement = e.originalTarget; } function appInit() { if (typeof (window.addEventListener) !== "undefined") { window.addEventListener("focus", focusHandler, true); } Sys.WebForms.PageRequestManager.getInstance().add_pageLoading(pageLoadingHandler); Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoadedHandler); } function pageLoadingHandler(sender, args) { lastFocusedControlId = typeof (document.activeElement) ==…

Send bulk Email in asp.net using excel file

When you want to send the mail to multiple person email id and your data exists in the excel file like email address and his name. you can accomplish this task using asp.net and c#. In C# under System.Net.Mail and System.Net namespace you can use classes which can help us to send mail effortlessly.

I am giving some sample code to understand the concept

Following is aspx design Page Sample


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LogDatails.aspx.cs" Inherits="LogDatails" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml" ><headrunat="server"><title>Untitled Page</title></head><body><formid="form1" runat="server"><div><a href="Default.aspx">Back</a><asp:GridViewID="GridView1&q…

404 error on report viewer contorol in asp .net while hosting on IIS 7 issue solved

If you are facing the problem rendering report viewer elements while loading the report viewer on browser

 Why it happens?

The answer is IIS7 Handler Mappings does not contain Reserved.ReportViewerWebControl.axd httpHandler, and therefore unable to render the ReportViewer elements needed by the JavaSript.


 What is the Solution?

Open Internet Information Services (IIS) Manager and select your Web application.Under IIS area, double-click on Handler Mappings icon.At the Action pane on your right, click on Add Managed Handler.At the Add Managed Handler dialog, enter the following:
Request path: Reserved.ReportViewerWebControl.axd
Type: Microsoft.Reporting.WebForms.HttpHandler
Name: Reserved-ReportViewerWebControl-axdClick OK.
What happens to your web application after you do above setting in IIS ?



Reserved-ReportViewerWebControl-axd handler is now added to your Handler Mappings list. Notice that the following line has also been added to your Web.config file under the system.webserver's h…

Encrypt web.Config sections using c# in asp.net

To give secuity to to your web application you need to make your applications secured you can encrypt the certain sections of web.config . To accomplish this task microsoft has provided library in the namespace System.Web.Configuration.
To Encrypt the web.config section you can use the following code using System.Configuration.Provider; using System.Configuration.Assemblies; using System.Web.Configuration; Configuration confi = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection section = confi.ConnectionStrings; section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); To Decrypt the web.config section you can use the following code using System.Configuration.Provider; using System.Configuration.Assemblies; using System.Web.Configuration; Configuration confi = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection section = confi.ConnectionStrings; section.Sec…

Regular Expression for numeric field in Asp.net 2.0 & 3.5

Any new developer needed to understand importance of the validation in their application to avoid future errors or bug in application. For this purpose developer must ensure the user input to their application is proper and well handled to avoid future bug or error in the application. In the list of validation the important validation is numeric validation. in numeric validation user must enter or application must prompt the user to enter only numeric field. In asp.net we/developer normally use the Regular Expression Validation but proper regulion expression is as follows ^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$Use this to restrict the user to enter Only numeric fieldgive me ur feedback if anyEnjoy

Add MouseOver and Mouseout effect to asp.net Calendar Control

When I thought that give some interesting effect to calendar control, which will improve look and feel of the Calendar

I started working on it and I created the following code which I want to share following is my design code....

<div> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black" BorderStyle="Solid" CellSpacing="1" Font-Names="Verdana" Font-Size="9pt" ForeColor="Black" Height="250px" NextPrevFormat="ShortMonth" onselectionchanged="Calendar1_SelectionChanged" Width="779px" ondayrender="Calendar1_DayRender"> <SelectedDayStyle BackColor="#333399" ForeColor="White" /> <TodayDayStyle BackColor="#999999" ForeColor="White" /> <OtherMonthDayStyle ForeColor="#999999" />…