Skip to main content

Posts

Showing posts from August, 2013

Easy Way Running Background Tasks in ASP.NET

I found that Easy Way Running  Background Tasks in ASP.NET , Occasionally, there might be some activity in your web application that should trigger the need for some code to execute at a later date. One of the most common cases is sending an email (reminder, change digest, feedbacks etc), but there are other many uses too. You might want to defer some processing intensive activity to off hours. In my most recent case, I needed to check for changes to an purchased/installed application’s db and replicate them to another product every 5 to 10 minutes or so. I’ve solved similar problems before by: From the web application, inserting a row in a ‘scheduled tasks’ database with a time to execute and a script url to run Creating an running a windows service somewhere that wakes up every 10 minutes or so, looks at the table for ‘due’ items, and opens a request to the url This works, but it has some drawbacks. You have to learn how to build and deploy a service.  Not partic

Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null. Parameter name: handler

Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null. Parameter name: handler This is a very common exception in the Microsoft Ajax Library, and just means you've got something named wrong or you are missing a parameter.  Sometimes you might just have the wrong element id set somewhere as a parameter, and this will throw the exception. So please make sure the necessary property target of some control is still exist on the page after executing the server code. If it is Visible=flase brings on this problem exactly, you can use Style["display"]="none" to hide the control. So please try to change the code blow: From: lnkLeft.Visible =false; lnkRight.Visible = true; to: <style>  .myclass { Display:none;  }  </style> lnkLeft.Attributes.Remove("class"); lnkLeft.Attributes.Add("class", " myclass ");

Send Templated Emails Using MailDefinition Object in asp.net

Sending Email using Templates Asp.net: Previous post explained about the Sending Email from Asp.net With Dynamic Content  Recently I Was found a better way to format my email messages in ASP.NET using the MailDefinition object. It lets you to use an email template and define tokens which you want to replace in it. This helps keep the presentation and business layers clean & separate and lets the designers go in and edit the email templates without having to navigate the StringBuilder. This article explains how to send email using ASP.NET. Yes, there are many other articles that cover sending email via .NET, I found that many articles suggest you create your HTML email using a string with the HTML markup in it. In this article we will look at a more detailed solution. One in which we use a regular HTML file as our template for the email. The template file will be a standard HTML file with the exception of some placeholders that we will use to populate our content and i

How to Select Data in DataTable using Select Method

In This Post I  Am going to Explain DataTable has a Select method . This method receives a string expression that specifies what rows you want to handle. Select makes DataTables act more like small databases. Previous Post I was explained about How to find master page control on content page in asp.net , How can i create a simple xml file and store it in my system in asp.net. Gets an array of DataRow objects. This member is overloaded. For complete information about this member, including syntax, usage, and examples Select Method without Expression private void GetRows() {     // Get the DataTable of a DataSet.     DataTable table = DataSet1.Tables["Suppliers"];     DataRow[] rows = table.Select();     // Print the value one column of each DataRow.     for(int i = 0; i < rows.Length ; i++)     {         Console.WriteLine(rows[i]["CompanyName"]);     } } Select Method with Expression Public void GetData()     { //  Create table.

How to find master page control on content page in asp.net

You can write code in content pages that references properties, methods, and controls in the master page, with some restrictions. The rule for properties and methods is that you can reference them if they are declared as public members of the master page. This includes public properties and public methods. You can reference controls on the master page independently of referencing public members. A Visual Studio project with source code is available to accompany this topic: Download . To reference a public member on the master page Add a @ MasterType directive in the content page. In the directive, set the VirtualPath attribute to the location of the master page, as in this example: <%@ MasterType virtualpath="~/Masters/Master1.master" %> This directive causes the content page's Master property to be strongly typed. Write code that uses the master page'

How to Share Image to my Facebook page using asp.net

Solution 1 : You can use of stream publish method, Here is the sample demo url by using this method it is also possible to share video, flash and mp3 aslo http://demo.vatlab.net/StreamPublish.aspx http://sudiptasanyal.blogspot.in/2011/09/share-image-with-facebook-in-aspnet.html Solution 2: Use of Graph API , refer more about http://www.aspsnippets.com/Articles/Share-Image-Photo-Pictures-on-Facebook-in-ASPNet-using-Graph-API.aspx

How can i create a simple xml file and store it in my system in asp.net

How Creating a simple xml file and store it in my system using asp.net and C#.net public class GenerateXml {     private static void Main() {         XmlDocument doc = new XmlDocument();         XmlNode docNode = doc.CreateXmlDeclaration("1.0", "UTF-8", null);         doc.AppendChild(docNode);         XmlNode productsNode = doc.CreateElement("products");         doc.AppendChild(productsNode);         XmlNode productNode = doc.CreateElement("product");         XmlAttribute productAttribute = doc.CreateAttribute("id");         productAttribute.Value = "01";         productNode.Attributes.Append(productAttribute);         productsNode.AppendChild(productNode);         XmlNode nameNode = doc.CreateElement("Name");         nameNode.AppendChild(doc.CreateTextNode("Java"));         productNode.AppendChild(nameNode);         XmlNode priceNode = doc.CreateElement("Price");         pri

How Generate HTML e-mail body in C# using templates

I think that any modern piece of software today, needs to send e-mail. Whether it being password recovery e-mails, rich reports, newsletters or anything else – being able to easily see and customize the look and feel of your e-mails is vital. So, the worst way I could think of is having your HTML hidden away in some StringBuilder.Append() hell. The best solution (in my opinion) would be, if you could have plain old HTML files with parameters like <#FirstName#> so you could dynamically replace those at run time. The MailDefinition class Using the  MailDefinition  class is pretty straight forward. You use the  MailDefinition  class to create an instance of  MailMessage , which you can send straightaway More About Refer : http://martinnormark.com/generate-html-e-mail-body-in-c-using-templates/ http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.maildefinition.aspx http://stackoverflow.com/questions/886728/generating-html-email-body-in-c-sharp h

How to Approve New Users With Confirmation Email Using CreateUserWizard Control in ASP.Net

In this article I will explain how to approve new users created using CreateUserWizard with a confirmation email in ASP.NET. Introduction In this article first we will configure a CreateUserWizard control using SQLMembersipProvider. Then an SMTP mail setting is configured to send a confirmation email to new users registered using this CreateUserWizard control. A user is approved when he clicks the confirmation email sent to his given email address. Refer More about : http://www.c-sharpcorner.com/uploadfile/deepak.sharma00/how-to-approve-new-users-with-confirmation-email-using-creat/  Related posts  http://forums.asp.net/p/1205725/2110325.aspx

How to install NuGet-packages Locally

Hosting Your Own NuGet Feeds Some companies restrict which third-party libraries their developers may use. Therefore, they might not want developers to have access to everything in the official NuGet feed, or they might have a set of proprietary libraries they want to make available in addition to the official feed. In these scenarios, you can set up a custom NuGet feed, and you can configure Visual Studio to offer that feed instead of or in addition to the official feed. A feed can be local (a folder on the local machine or a network folder) or remote (an internet URL). Refer More about http://docs.nuget.org/docs/creating-packages/hosting-your-own-nuget-feeds

What is Visual Studio Page Inspector tool

Description Page Inspector is a new tool that brings browser diagnostics tools into Visual Studio and provides an integrated experience between the browser, ASP.NET, and source code. It renders a web page (HTML, Web Forms, ASP.NET MVC, or Web Pages) directly within Visual Studio 11 and lets you examine both the source code and the resulting output. Page Inspector enables you to easily decompose a website, rapidly build pages from the ground up, and quickly diagnose issues. In this lab, you will explore how to use Page Inspector. Overview In this Hands-on Lab, you will discover a new tool to find and fix web page issues in Visual Studio - the Page Inspector. Page Inspector is a new tool that brings browser diagnostics tools to Visual Studio and provides an integrated experience among the browser, ASP.NET, and source code. It renders a web page (HTML, Web Forms, ASP.NET MVC, or Web Pages) directly within the Visual Studio IDE and lets you examine both the source code and the r

ASP.NET Menu and SiteMap Security Trimming (plus a trick for when your menu and security don't match up)

Summary ASP.NET 2005 introduced a pretty solid menu which is integrated with a configuration driven sitemap. The cool part is that the menu can be hooked in with your security roles, so you don't have to worry about hiding or showing menu options based on the user -  the menu options are automatically kept in sync with what the user is allowed to see . We'll talk about how to set this up, using an example from a website I worked on recently. If you're familiar with ASP.NET sitemaps and menus, skip to the end to read a trick for working around cases when you want to do something more complex, such as have a page to be accessible to a user role, but not to show up in the menu. The  Video.Show  site was originally planned to have only one class of user, with no user restrictions other than requiring a quick registration before commenting on videos or uploading videos. With that being the case, we just included a static menu in the masterpage, defined as <asp:MenuIte

How to Generate ASP.NET Membership Sql Script

Hi Here is the article on  that walks you through ASP.NET Membership schema using aspnet_regsql utility. Note that regard less of SQL Server version this step by step guide works fine. http://weblogs.asp.net/sukumarraju/archive/2009/10/02/installing-asp-net-membership-services-database-in-sql-server-expreess.aspx Once you install Membership database here is the article that explains how to configure to use with in your application. http://weblogs.asp.net/sukumarraju/archive/2010/01/17/configuring-web-application-to-utilise-asp-net-application-services-database.aspx For you further info/help you can find video tutorials and articles at www.asp.net/learn/security www.asp.net/learn/security-videos

Remove all Html Tags in pdf file

If  you want to remove all of the HTML tags contained within your PDF form? I'll list two of the major options, using an HTML Parser and using a Regular Expression to tackle this issue. Option 1 : Use the HTML Agility Pack  The HTML Agility Pack is an agile parser that reads, writes and handles most situations that you would need to do involving HTML in .NET. (As a bonus is it also available through NuGet) From this related Stack Overflow discussion, you can see the code listed below to strip all of the HTML tags from some text : HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(Properties.Resources.HtmlContents); var text = doc.DocumentNode.SelectNodes("//body//text()").Select(node => node.InnerText); StringBuilder output = new StringBuilder(); foreach (string line in text) {    output.AppendLine(line); } string textOnly = HttpUtility.HtmlDecode(output.ToString()); I haven't worked with the HTML Agilty Pack, however I have heard nothing but

Sqldatasource Filterexpression example in asp.net

Here is the example for Sqldatasource filterexpression example in asp.net <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   <script runat="server">   </script>   <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title>asp.net SqlDataSource example: using FilterParameters, FilterExpression</title> </head> <body>     <form id="form1" runat="server">     <div>         <h2 style="color:Red">FilterParameters Example</h2>         <asp:SqlDataSource              ID="SqlDataSource1"              runat="server"              ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"              SelectCommand="SELECT ProductID

Asp.net GridView Sorting example: How to sort GridView Data

Here is the example of how to sort the data in gridview by using the sqldatasouce in asp.net . <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   <script runat="server">   </script>   <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>asp.net GridView Sorting example: how to sort GridView Data</title> </head> <body>     <form id="form1" runat="server">     <div>         <h2 style="color:Teal">Sorting In GridView</h2>         <asp:SqlDataSource              ID="SqlDataSource1"              runat="server"              ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"              SelectCom

What is the difference between a process and a thread

Both processes and threads are independent sequences of execution. The typical difference is that threads (of the same process) run in a shared memory space, while processes run in separate memory spaces. I'm not sure what "hardware" vs "software" threads might be referring to. Threads are an operating environment feature, rather than a CPU feature (though the CPU typically has operations that make threads efficient). Erlang uses the term "process" because it does not expose a shared-memory multiprogramming model. Calling them "threads" would imply that they have shared memory. Process: An executing instance of a program is called a process. Some operating systems use the term ‘task‘ to refer to a program that is being executed. A process is always stored in the main memory also termed as the primary memory or random access memory. Therefore, a process is termed as an active entity. It disappears if the machine is re

jQuery - Allow Alphanumeric (Alphabets & Numbers) Characters in Textbox using JavaScript

Here i will explain how to use  JQuery  to  allow only alphanumeric characters in textbox  or make textbox to allow only alphabets & numbers using  JQuery . < html   xmlns ="http://www.w3.org/1999/xhtml"> < head > < title > jQuery Allow only alphanumeric characters in textbox </ title > < script   type ="text/javascript"   src ="http://code.jquery.com/jquery-1.8.2.js"></ script > < script   type ="text/javascript"> $( function  () { $( '#txtNumeric' ).keydown( function  (e) { if  (e.shiftKey || e.ctrlKey || e.altKey) { e.preventDefault(); }  else  { var  key = e.keyCode; if  (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90) || (key >= 48 && key <= 57) || (key >= 96 && key <= 105))) { e.preventDefault(); } } }); }); </ script > </ head >