Posts

Showing posts with the label Asp.Net

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.acti

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 " > < html xmlns =" http://www.w3.org/1999/xhtml " > < head runat =" server " > < title > Untitled Page < / title > < / head > < body > < form id =" form1 " runat =" server " >

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-axd Click  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

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 field give me ur feedback if any Enjoy

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 ForeCo