ASP.NET 4.5 and ASP.NET Core 1 Hosting BLOG

Tutorial and Articles about ASP.NET 4.0 and the latest ASP.NET 4.5 Hosting

ASPHostPortal.com Proudly Announces DotNetNuke 7.3.4 Hosting

clock December 22, 2014 11:12 by author Dan

ASPHostPortal.com, The Best, Cheap and Recommended ASP.NET Hosting proudly announces DotNetNuke 7.3.4 Hosting with a combination of affordable price, fast & stable network and high customer satisfaction rate. ASPHostPortal.com provides full trust web hosting services for DotNetNuke 7.3.4 site.

DNN (formerly DotNetNuke) provides a suite of solutions for creating rich, rewarding online experiences for customers, partners and employees. DNN products and technology are the foundation for 750,000+ websites worldwide. In addition to commercial CMS and social community solutions, DNN is the steward of the DotNetNuke Open Source Project.

DNN Platform 7.3.4 has been released. The 7.3.4 release is a stabilization release. DNN 7.3.4 is a smaller maintenance release than normal and is focused on addressing the most serious platform issues. This version release to solve some issue, such as : fixed issue where site settings were not updating correctly in multi-language installations, fixed issue where partial site templates were not working correctly with child sites, fixed issue where links created in Telerik RadEditor were not correct and many others.

ASPHostPortal.com, a windows-based hosting service provider offers the most reliable and stable DotNetNuke 7.3.4 web hosting infrastructure on the net with great features, fast and secure servers. Customer’s site will be hosted in USA, Amsterdams or Singapore based server. All of our windows hosting plan supports DotNetNuke 7.3.4 and you can install DotNetNuke 7.3.4 with just one click. We offer professional DotNetnuke 7.3.4 site start from $5/month. The following are the reasons why you should choose and keep trust with us :

Uptime & Support Guarantees
We are so confident in Windows hosting services, we not only provide you with a 30 days money back guarantee, but also give 99.9% uptime guarantee.

Best and Friendly Support
Our support team is extremely fast and can help you with setting up and using DotNetNuke 7.3.4 on your account. Our customer support will help you 24 hours a day, 7 days a week and 365 days a year.

Dedicated Application Pool
Your site will be hosted using isolated application pool in order to meet maximum security standard and reliability.

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. With the DotNetNuke 7.3.4 in their hosting deal will make ASPHostPortal continue to be the Best ASP.NET hosting providers. To learn more about DotNetNuke 7.3.4 Hosting, please visit http://asphostportal.com/DotNetNuke-734-Hosting

About ASPHostPortal.com :

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. ASPHostPortal.com has ability to support the latest Microsoft and ASP.NET technology, such as: such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. ASPHostPortal include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and architecting highly scalable solutions. ASPHostPortal.com strives to supply probably the most technologically advanced hosting solutions available to all consumers the world over. Protection, trustworthiness, and performance are on the core of hosting operations to make certain each and every website and/or software hosted is so secured and performs at the best possible level.



ASP.NET Hosting -ASPHostPortal.com :: Step by Step to Repair Dropdown Boxes in ASP.NET Datagrids

clock December 22, 2014 06:46 by author Dan

Introduction

Today, I will explain Step by Step to Repair Dropdown Boxes in ASP.NET Datagrids. Alright, this issue isn't silverlight, yet I did experience it in my day work. Truth be told, I've experienced it a few times, so I thought I would compose it up so I can discover it once more.

Error

You compose a page that contains an updatable datagrid, which, when in Editmode, contains a dropdown rundown containing lookup things. The Dropdownbox does not populate, and (later when you get it working) the correct listitem is not chosen.

Cause

Since the Dropdownbox down not existing when the page loads, there is nothing to tie.

Step by Step

You need to append your occasions to some non-standard page occasions to get it to work. The pertinent piece of the .aspx page is underneath (placed this in your datagrid)

<asp:TemplateColumn HeaderText=”Tactic Category”>

<HeaderStyle Font-Size=”Large” Font-Bold=”true” />
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,”TacticCatName”)%>
</ItemTemplate>
<EditItemTemplate>
<%–Notice the GetCat() routine here as the datasource.–%>
<asp:DropDownList id=”ddTacticCatList” runat=”server” DataSource=”<%# GetCat() %>” DataTextField=”TacticCatName” DataValueField=”TacticCatID”>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>

Your code-behind page should look like this (in C#)

private void MainCode()
{
string strID = Request.QueryString["id"].ToString();
//custom code to get the relevant dataset for the entire datgrid
DataSet ds = LMR.TacticSubCatList(strID);
//custom code to bind to the datagrid
Utility.DGDSNullCheck(ds, dgTacticSubCatList, lblTacticSubCatList, “There are no tactic subcategories in the database at this time.”);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MainCode();
}
}

protected void dgTacticSubCatList_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//grab the index
dgTacticSubCatList.EditItemIndex = e.Item.ItemIndex;
MainCode();
}

protected void dgTacticSubCatList_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//get the id value of the selected datagrid item
int intTacticSubCatID = (int)dgTacticSubCatList.DataKeys[(int)e.Item.ItemIndex];

//this gets our textbox, also in the datagrid
TextBox EditText = null;
EditText=(TextBox)e.Item.FindControl(“tbTacticSubCatName”);
string strEditText = Convert.ToString(EditText.Text);

//get the value of our dropdown list
DropDownList dd = (DropDownList)e.Item.FindControl(“ddTacticCatList”);
string strTacticCatID = dd.SelectedValue.ToString();
//do our database update
LMR.TacticSubCatEdit(intTacticSubCatID.ToString(),strTacticCatID,strEditText);
//reset the datagrid
dgTacticSubCatList.EditItemIndex = -1;
//give feedback and rebind
lblFeedback.Text = “Your changes have been applied.”;
MainCode();
}

protected void dgTacticSubCatList_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgTacticSubCatList.EditItemIndex = -1;
MainCode();
}
protected DataTable GetCat()
{
//here is where we get the dataset to populate the dropdown list – it does have to go in an independant function
DataSet ds = LMR.TacticCatList();
return ds.Tables[0];
}

protected void dgTacticSubCatList_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.EditItem)
{
//we set the selcted index in the ItemDataBound event
string strID = Request.QueryString["id"].ToString();
string strSubCatID = dgTacticSubCatList.DataKeys[(int)e.Item.ItemIndex].ToString();
Holder.TacticSubCat tsc = LMR.GetTacticSubCat(strSubCatID);
DropDownList dd = (DropDownList)e.Item.FindControl(“ddTacticCatList”);
dd.SelectedIndex =dd.Items.IndexOf(dd.Items.FindByValue(strID));
}
}

It's as simple as that. Hopefully this article will be usefull for you.



ASP.NET 4.5 Hosting - ASPHostPortal :: How to Drag Drop Elements in ASP.NET MVC 5 using HTML 5, Web API and jQuery

clock December 22, 2014 05:24 by author Mark

Providing rich web UI experiences like Charts, Editable tabular interface, offline capabilities, dragging-dropping data on the page etc. can be a challenging task. To implement these features, a developer must plan the application based upon different browsers capabilities. A couple of years ago, this was achievable with a lot of efforts using some complex JavaScript code.

As the web progressed, modern browsers has made it possible to take web development to the next level. To complement, there are several libraries like jQuery, Angular, DOJO, etc. that can provide new UI rich features to enhance your applications. But wouldn’t it be nicer if the HTML itself provides some of these cool features using markup?
HTML5 has been developed with the current and future browser development in mind. Apart from being backward compatible, HTML5 contains many new elements and APIs for adding Rich UX capabilities to the application. Drag-Drop is one such useful feature available in HTML5 that can be used for data management on the page.
In HTML 5, an element can be made draggable using draggable=true in the markup. To monitor the process of drag-drop, we need to make use of the following events: dragstart, drag, dragenter, dragleave, dragover, drop, dragend.
The process of implementation has the following elements:

  • The source element applied with attribute draggable=true.
  • The data payload which means the data to be dragged and dropped.
  • The target where the drop is made.

Drag-Drop in ASP.NET MVC 5 using HTML 5, Web API and jQuery

To implement the Drag-Drop application, we will be using the following technologies:
ASP.NET MVC 5
WEB API with Attribute Routing
jQuery

  • Step 1: Open Visual Studio 2013 (the application uses Ultimate with Update 3), and create an Empty MVC application.
  • Step 2: In the App_Data folder of the application add a new SQL Server database with the name ‘Application.mdf’ as below:

In this database, add a new table called ‘Products’ using the following script:
CREATE TABLE [dbo].[Products] (
    [ProductId]   INT          IDENTITY (1, 1) NOT NULL,
    [ProductName] VARCHAR (50) NOT NULL,
    [Quantity]    INT          NOT NULL,
    PRIMARY KEY CLUSTERED ([ProductId] ASC)
);

The above table will contain products which we will fetch in our View.

  • Step 3: In the Models folder, add a new EntityFramework with the name ApplicationEDMX. In the wizard that comes up, select the Application.mdf database and the Products table designed in the above step. After completing the wizard, the following table mapping gets displayed.

  • Step 4: In the controllers folder, add a new Empty WEB API Controller with the name ProductsAPIController. In this API controller add the following code:

using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using A1_HTML5_DragDrop.Models;
namespace A1_HTML5_DragDrop.Controllers
{
    public class ProductsAPIController : ApiController
    {
        ApplicationEntities ctx;
 
        public ProductsAPIController()
        {
            ctx = new ApplicationEntities();
        }
 
        [Route("Products")]
        public IEnumerable<Product> GetProducts()
        {
            return ctx.Products.ToList();
        }
    }
}

The above code declares an object of ApplicationEntities, which got generated using EntityFramework. The GetProducts() returns a list of products. This method is applied with an Attribute Route ‘[Route(“Products”)]’ which will provide the URL to make call to this method using client-side framework (e.g. ajax method). You can read more on Attribute routing in my other article Practical Use of ASP.NET Web API Attribute Routing in an MVC application.

  • Step 5: In the controllers folder, add a new Empty MVC controller of the name ProductController. This controller class will generate an Index method. Scaffold a new Empty view from the Index method.
  • Step 6: Add the following markup in the Index view:

<table>
    <tr>
        <td>
            <h1>Product List</h1>
        </td>
        <td>
            <h1>Selected Products</h1>
        </td>
    </tr>
    <tr>
        <td>
            <div id="dvleft">
                <ul id="lstproducts">
                </ul>
            </div>
        </td>
        <td>
            <div id="dvright">
                <ul id="lstselectedproducts"></ul>
            </div>
        </td>
    </tr>
</table>

The above markup has a table with two rows. The first row shows headers for Product List and selected products. The second row contains <div>s containing list in it. The ‘lstproducts’ list will show the Products retrieved from the server. The ‘lstselectedproducts’ will show selected products by the end-user using Drag-Drop.
Add the following styles in the View (better to use a separate stylesheet but I will keep it here for readability):
<style type="text/css">
    table, td {
        background-color:azure;
     border:double;
    }
    #dvright,#dvleft {
        background-color:azure;
       height:200px;
       width:300px;
    }
</style>

  • Step 7: In the page add the following Script:

<script type="text/javascript">
    $(document).ready(function () {
        loadProducts();
        //Function to set events for Drag-Drop
        function setEvents() {
            var lstProducts = $('li');
            //Set Drag on Each 'li' in the list
                $.each(lstProducts, function (idx, val) {
                    $('li').on('dragstart', function (evt) {
                        evt.originalEvent.dataTransfer.setData("Text", evt.target.textContent);
                        evt.target.draggable = false;
                    });
                });
            //Set the Drop on the <div>
                $("#dvright").on('drop', function (evt) {
                    evt.preventDefault();
                    var data = evt.originalEvent.dataTransfer.getData("Text");
                    var lst = $("#lstselectedproducts");
                    var li = "<li>"+data+"</li>";
                    li.textContent = data;
                    lst.append(li);
                });
 
            //The dragover
                $("#dvright").on('dragover', function (evt) {
                    evt.preventDefault();
                });
        }
        ///Function to load products using call to WEB API
        function loadProducts() {
            var items="";
            $.ajax({
                url: "/Products",
                type: "GET"
            }).done(function (resp) {
                $.each(resp, function (idx, val) {
                    items += "<li draggable='true'>" + val.ProductName + "</li>";
                });
                $("#lstproducts").html(items);
                setEvents();
            }).error(function (err) {
                alert("Error! " + err.status);
            });
        }
    });
</script>

The script has the following specifications:

  • The function ‘loadProducts()’ makes an ajax call to WEB API. When the call is successful, the iteration is done through the response. This iteration adds the <li> tag in the ‘lstproducts’ list with the draggable attribute set to true.
  • The function ‘setEvents()’ performs the following two step operations:
  • subscribe to the ‘dragstart’ event for each <li> and set the data transfer with the ‘Text’ property. This is the text content of the <li> selected. Once any <li> is dragged, the drag on the same is disabled using evt.target.draggable =false; statement.
  • The <div> of id ‘dvright’ is subscribed to ‘drop’ event, it accepts the dragged Text. Once the text is accepted, it is set to the <li> which is dynamically appended in the list with id as ‘lstselectedproducts’.
  • Step 8: Run the application, the Products data gets loaded:

    Drag the Product from the ‘Product List’ and drop it in the ‘Selected Products’ as seen here:

    • The above Red Mark shows the Drag Action. Once the drop operation is over the result will be as seen here:

Conclusion:

The HTML 5 Native support for Drag-Drop provides an easy mechanism of handling Data as well as UI operations. Since the support is native to HTML 5, no additional library is required.



ASP.NET 4.5 Hosting - ASPHostPortal.com :: Enabling Unobtrusive Validation From Scratch in ASP.NET 4.5 Webforms

clock December 19, 2014 04:55 by author Ben

I used to be fiddling with ASP.NET 4.5 and Visual Studio 2012 particularly with all the new Validation attributes and i identified they function great, specially the new unobtrusive validation, then I attempted to permit this sort of validation over a new Vacant Net Software, and that i identified that this just isn't out-of-the-box, you'll need to create some configurations to your Net Application.

You'll find a few ways to allow the unobtrusive validation over a Internet Software:

Through the web.config file

<configuration> 
  <appsettings> 
   <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms"> 
  </add></appsettings> 
 </configuration> 

Via the Global.asax file

protected void Application_Start(object sender, EventArgs e)
{
   ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;
}

On each page:

protected void Page_Load(object sender, EventArgs e)
{
   this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.WebForms;
}

To disable the unobtrusive validation set the UnobtrusiveValidationMode property to None. Unobtrusive validation is actually enabled by default in ASP.Net 4.5.

We'll start with a simple example, create an Empty Web Application and add a MasterPage called Site.master and a content page for this master called Default.aspx.
Add the following code to the Default.aspx file:

<asp:TextBox runat="server" ID="txt" />
    <asp:RequiredFieldValidator ErrorMessage="txt is required" ControlToValidate="txt" runat="server" Text="*" Display="Dynamic" />
    <asp:Button Text="Send info" runat="server" />

If you try to run a simple ASPX page using a validator, the following exception will be thrown:

    "WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive)". Before fixing this, let's disable the unobtrusive validation to see the result.

On the page:

protected void Page_Load(object sender, EventArgs e)
{
   this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
}

Now run the page and the validation will work as it used to work in ASP.Net 4.0 If you examine the rendered HTML, you will see that the gross inline script is rendered:

<script type="text/javascript">
//<![CDATA[
var Page_Validators =  new Array(document.getElementById("ContentPlaceHolder1_ctl00"));
//]]>
</script>

<script type="text/javascript">
//<![CDATA[
var ContentPlaceHolder1_ctl00 = document.all ? document.all["ContentPlaceHolder1_ctl00"] : document.getElementById("ContentPlaceHolder1_ctl00");
ContentPlaceHolder1_ctl00.controltovalidate = "ContentPlaceHolder1_txt";
ContentPlaceHolder1_ctl00.errormessage = "txt is required";
ContentPlaceHolder1_ctl00.display = "Dynamic";
ContentPlaceHolder1_ctl00.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
ContentPlaceHolder1_ctl00.initialvalue = "";
//]]>
</script>


<script type="text/javascript">
//<![CDATA[

var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}

function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
       
document.getElementById('ContentPlaceHolder1_ctl00').dispose = function() {
    Array.remove(Page_Validators, document.getElementById('ContentPlaceHolder1_ctl00'));
}
//]]>
</script>

Now let's re-enable the unobtrusive validation. In order to fix the previous exception, we need to install the following Nuget packages: (I like to install jQuery first to get the latest version, although this is not required.)

  1. jQuery
  2. ASPNET.ScriptManager.jQuery
  3. Microsoft.AspNet.ScriptManager.MSAjax
  4. Microsoft.AspNet.ScriptManager.WebForms

At this point, if you run the application again, the exception will be gone =) how cool eh?. This is because the following Nuget packages automatically register the scripts needed with the ScriptManager control.

Let's examine the code added by these Nuget packages using ILSpy:

AspNet.ScriptManager.jQuery

public static class PreApplicationStartCode
    {
        public static void Start()
        {
            string str = "1.8.1";
            ScriptManager.ScriptResourceMapping.AddDefinition("jquery", new ScriptResourceDefinition
            {
                Path = "~/Scripts/jquery-" + str + ".min.js",
                DebugPath = "~/Scripts/jquery-" + str + ".js",
                CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + str + ".min.js",
                CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-" + str + ".js",
                CdnSupportsSecureConnection = true,
                LoadSuccessExpression = "window.jQuery"
            });
        }
    }

Microsoft.AspNet.ScriptManager.MSAjax

public static void Start()
{
    ScriptManager.ScriptResourceMapping.AddDefinition("MsAjaxBundle", new ScriptResourceDefinition
    {
        Path = "~/bundles/MsAjaxJs",
        CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5/6/MsAjaxBundle.js",
        LoadSuccessExpression = "window.Sys",
        CdnSupportsSecureConnection = true
    });
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjax.js", "window.Sys && Sys._Application && Sys.Observer");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxCore.js", "window.Type && Sys.Observer");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxGlobalization.js", "window.Sys && Sys.CultureInfo");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxSerialization.js", "window.Sys && Sys.Serialization");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxComponentModel.js", "window.Sys && Sys.CommandEventArgs");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxNetwork.js", "window.Sys && Sys.Net && Sys.Net.WebRequestExecutor");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxHistory.js", "window.Sys && Sys.HistoryEventArgs");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxWebServices.js", "window.Sys && Sys.Net && Sys.Net.WebServiceProxy");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxTimer.js", "window.Sys && Sys.UI && Sys.UI._Timer");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxWebForms.js", "window.Sys && Sys.WebForms");
    PreApplicationStartCode.AddMsAjaxMapping("MicrosoftAjaxApplicationServices.js", "window.Sys && Sys.Services");
}
private static void AddMsAjaxMapping(string name, string loadSuccessExpression)
{
    ScriptManager.ScriptResourceMapping.AddDefinition(name, new ScriptResourceDefinition
    {
        Path = "~/Scripts/WebForms/MsAjax/" + name,
        CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5/6/" + name,
        LoadSuccessExpression = loadSuccessExpression,
        CdnSupportsSecureConnection = true
    });
}

Microsoft.AspNet.ScriptManager.WebForms

public static void Start()
{
    ScriptManager.ScriptResourceMapping.AddDefinition("WebFormsBundle", new ScriptResourceDefinition
    {
        Path = "~/bundles/WebFormsJs",
        CdnPath = "http://ajax.aspnetcdn.com/ajax/4.5/6/WebFormsBundle.js",
        LoadSuccessExpression = "window.WebForm_PostBackOptions",
        CdnSupportsSecureConnection = true
    });
}

As you can see these Nuget packages automatically register the scripts using the ScriptManager object (besides installing the required JavaScript files)

Run the application and examine the rendered HTML. You will note that it's much cleaner now, in this case the inline script has been moved to an external file that can be rendered using bundles to increase performance. The rendered script looks like:

<script src="Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js" type="text/javascript"></script>
<script src="Scripts/jquery-1.8.1.js" type="text/javascript"></script>

Much better right?. Notice how ASP.Net used HTML5 custom attributes:

<input name="ctl00$ContentPlaceHolder1$txt" type="text" id="ContentPlaceHolder1_txt" />
    <span data-val-controltovalidate="ContentPlaceHolder1_txt" data-val-errormessage="txt is required" data-val-display="Dynamic" id="ContentPlaceHolder1_ctl00" data-val="true" data-val-evaluationfunction="RequiredFieldValidatorEvaluateIsValid" data-val-initialvalue="" style="display:none;">*</span>
    <input type="submit" name="ctl00$ContentPlaceHolder1$ctl01" value="Send info" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ContentPlaceHolder1$ctl01&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" />

The data-val-* are custom attributes used by the unobtrusive validation engine

If you click the button to trigger the validation you will be pleased to see that it works as expected...but we are not done yet =/

The settings we have applied won't work if you intend to use an UpdatePanel control (yeah the evil UpdatePanel again...). This is because this control requires a ScriptManager control on the page (or MasterPage) and we do not have any yet. So let's add a simple ScriptManager control to the master page and see what happens. Add the following code to the Site.master page right under the <form...

<asp:ScriptManager runat="server" ID="scriptManager">
        </asp:ScriptManager>

Run the page again and fire the validation... oops... the client validation has gone =( We only have server validation. I'm not sure why this happens but my best guess is that the just added ScriptManager control is overriding our code settings.

To fix it, change the declaration of the ScriptManager control on the Site.master page to:

<asp:ScriptManager runat="server" ID="scriptManager1">
        <Scripts>
            <asp:ScriptReference Name="MsAjaxBundle" />
            <asp:ScriptReference Name="jquery" />
            <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
            <asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
            <asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
            <asp:ScriptReference Name="GridView.js" Assembly="System.Web" Path="~/Scripts/WebForms/GridView.js" />
            <asp:ScriptReference Name="DetailsView.js" Assembly="System.Web" Path="~/Scripts/WebForms/DetailsView.js" />
            <asp:ScriptReference Name="TreeView.js" Assembly="System.Web" Path="~/Scripts/WebForms/TreeView.js" />
            <asp:ScriptReference Name="WebParts.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebParts.js" />
            <asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
            <asp:ScriptReference Name="WebFormsBundle" />
        </Scripts>
    </asp:ScriptManager>

Run the application and our little example will work again as expected

Sadly these new settings are the equivalent to the settings added by code and we need to add them to be able to use the traditional Microsoft AJAX controls.

There's one last thing we need to configure, this is because there's actually a bug with the ValidationSummary control.

To test it, update the Default.aspx page as follows:

<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <asp:TextBox runat="server" ID="txt" />
    <asp:RequiredFieldValidator ErrorMessage="txt is required" ControlToValidate="txt" runat="server" Text="*" Display="Dynamic" />
    <asp:Button Text="Send info" runat="server" />

Now run the page again, scroll down until you can see the button and click it... woot your page jumped to the top... the workaround to solve this little bug is to add the following code to the Site.master

<script>
            window.scrollTo = function () {

            };
        </script>

 



ASPHostPortal.com Proudly Launches nopCommerce 3.50 Hosting

clock December 16, 2014 11:13 by author Dan

ASPHostPortal.com, The Best, Cheap and Recommended ASP.NET Hosting proudly Launch nopCommerce 3.50 Hosting at affordable price, instant activation, and fast & stable network. ASPHostPortal.com provides full trust web hosting services for your nopCommerce 3.50 site. Full service and fully accountable, we expertly manage your hosting.

nopCommerce is an open source ecommerce software that contains both a catalog frontend and an administration tool backend. nopCommerce is a fully customizable shopping cart. It's stable and highly usable. From downloads to documentation, nopCommerce.com offers a comprehensive base of information, resources, and support to the nopCommerce community. Now, nopCommerce has released the new version (nopCommerce 3.50).

nopCommerce 3.50 is much faster and easier to use, there is a slew of design as well as performance changes. nopCommerce 3.50 now support rental products, new tax rules for Europe Union from 2015, better warehouse and inventory control. In this version, nopCommerce allow a store owner to define custom address attributes and see all existing extensions and themes in admin area. And now specification attributes support several types like option, custom text, HTML text and hyperlink.

Why to Host Your nopCommerce 3.50 Site with ASPHostPortal.com

Uptime & Support Guarantees
We are so confident in Windows hosting services, They will not only provide you with a 30 days money back guarantee, but also give you a 99.9% uptime guarantee.

Dedicated Application Pool
With us, your site will be hosted using isolated application pool in order to meet maximum security standard and reliability.

Security
We employ best in breed firewalls and perimeter network protection.

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. With the nopCommerce 3.50 in their hosting deal will make ASPHostPortal continue to be the Best ASP.NET hosting providers. To learn more about nopCommerce 3.50 Hosting, please visit http://asphostportal.com/ nopCommerce-3-50-Hosting

About ASPHostPortal.com :
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. ASPHostPortal.com has ability to support the latest Microsoft and ASP.NET technology, such as: such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. ASPHostPortal include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and architecting highly scalable solutions. ASPHostPortal.com strives to supply probably the most technologically advanced hosting solutions available to all consumers the world over. Protection, trustworthiness, and performance are on the core of hosting operations to make certain each and every website and/or software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal.com :: ASP.NET Patterns : MVC, MVP and MVVM

clock December 16, 2014 07:42 by author Ben

ASPHostPortal - In this article I would prefer to tell you just what the big difference in between these designs. Let’s commence with all the initial primary 1 - Model-View-Controller - it is a basic sample that applies in the several systems and every day tends to make simpler existence for programmers. If you ask computer software Architects about “How to apply this pattern”, I think you will get a pair of various answers and respectively a couple of answers. Basically, there is certainly 1 common point in these designs - is separation of User Interface (UI) from company logic, it allows do function for front-end developers not thinking about plan code. In the event you bear in mind college or university programming, it had been an enormous bunch of lines of code, composed in code behind (for instance) of .aspx documents, which is not a great practice.

 


MVC has a few key components: View (consumer interface), Product (company logic) and Controller (contains the logic that modifications the design because of to consumer steps, implements Use Situation). The fundamental idea of this pattern is that the controller and look at is determined by product, but the product will not depend on these two elements. It just permits you to definitely create and check a product without having realizing something concerning the sights and controllers. Preferably, the controller also will not must know about see (even though in follow this can be not often the situation) and, ideally, a single can switch controllers presentation, along with the exact same controller can be utilized for various sights (as an example, the controller might depends on person who is logged in). The consumer sees a check out, creates some motion, this motion redirects towards the controller and subscribes for adjustments from the product, controller makes particular operations with info design, and also the see will get the newest point out of the design and displays it for the consumer.

Implementation in ASP.NET looks like as follows (instance taken from MSDN [5]). Presentation - this can be a common aspx markup:

<html>
<body>
    <form id="start" method="post" runat="server">
        <asp:dropdownlist id="recordingSelect" runat="server" />
        <asp:button runat="server" text="Submit" onclick="SubmitBtn_Click" />
        <asp:datagrid id="MyDataGrid" runat="server" enableviewstate="false" />
    </form>
</body>
</html>

Model – a separate class, which has methods for obtaining data (model implementations often includes Data Access Level):

public class DatabaseGateway
{
   public static DataSet GetRecordings()
   {
     DataSet ds = ...
     return ds;
   }
 
   public static DataSet GetTracks(string recordingId)
   {
      DataSet ds = ...
      return ds;
   }
}

Example of a model is not the best in this case, but it’s still not always need to have a really describe the business model in the classes, sometimes it’s enough to work with DataSets. The most interesting thing is the implementation of the controller, in fact it’s code behind of aspx page

using System;
using System.Data;
using System.Collections;
using System.Web.UI.WebControls;
 
public class Solution : System.Web.UI.Page
{
    private void Page_Load(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet ds = DatabaseGateway.GetRecordings();
            recordingSelect.DataSource = ds;
            recordingSelect.DataTextField = "title";
            recordingSelect.DataValueField = "id";
            recordingSelect.DataBind();
        }
    }
 
    void SubmitBtn_Click(Object sender, EventArgs e)
    {
        DataSet ds = DatabaseGateway.GetTracks((string)recordingSelect.SelectedItem.Value);
 
        MyDataGrid.DataSource = ds;
        MyDataGrid.DataBind();
    }
    #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
        //
        // CODEGEN: This call is required by the ASP.NET Web Form Designer.
        //
        InitializeComponent();
        base.OnInit(e);
    }
 
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.submit.Click += new System.EventHandler(this.SubmitBtn_Click);
        this.Load += new System.EventHandler(this.Page_Load);
 
    }
    #endregion
}

This approach will allow us to easily write tests for the model, but not for the controller (of course, all things are possible, but we need to try).

[TestFixture]
public class GatewayFixture
{
    [Test]
    public void Tracks1234Query()
    {
 
        DataSet ds = DatabaseGateway.GetTracks("1234");
        Assertion.AssertEquals(10, ds.Tables["Track"].Rows.Count);
    }
 
    [Test]
    public void Tracks2345Query()
    {
        DataSet ds = DatabaseGateway.GetTracks("2345");
        Assertion.AssertEquals(3, ds.Tables["Track"].Rows.Count);
    }
 
    [Test]
    public void Recordings()
    {
        DataSet ds = DatabaseGateway.GetRecordings();
        Assertion.AssertEquals(4, ds.Tables["Recording"].Rows.Count);
 
        DataTable recording = ds.Tables["Recording"];
        Assertion.AssertEquals(4, recording.Rows.Count);
 
        DataRow firstRow = recording.Rows[0];
        string title = (string)firstRow["title"];
        Assertion.AssertEquals("Up", title.Trim());
    }
}


This sample also is made up from the 3 parts. Looking at the diagram, it really is distinct that for representation is not essential to subscribe for adjustments inside the product, the controller is renamed as Presenter, lets illustration learn about modifications. Current strategy allows you to develop an abstraction of representation. To apply this pattern, you should create interfaces of illustration. Every illustration can have interfaces with a sets of strategies and qualities which can be required for presenter, presenter initializes with correct interface, subscribes for the events of illustration and offers data when it necessary. This approach permits you to develop programs utilizing the methodology of TDD (Test-driven development). This pattern can be utilized to ASP.NET, let us take a look at the prior instance. Depart representation and product from your earlier example, and code behind of the page we'll modify just a little bit.

//Abstract View
public interface ISolutionView
{
    string SelectedRecord { get; }
    DataSet Recordings { set; }
    DataSet Tracks { set; }
}
 
//Presenter
public class SolutionPresenter
{
    private ISolutionView _view;
    
    public SolutionPresenter(ISolutionView view)
    {
        _view = view;
    }
    
    public void ShowTracks()
    {
        DataSet ds = DatabaseGateway.GetTracks(_view.SelectedRecord);
        _view.Tracks = ds;
    }
    
    public void Initialize()
    {
        DataSet ds = DatabaseGateway.GetRecordings();
        _view.Recordings = ds;
    }
}
 
 
//View
public class Solution : System.Web.UI.Page, ISolutionView
{
    private SolutionPresenter _presenter;
    
    private void Page_Load(object sender, System.EventArgs e)
    {
        if(!IsPostBack)
        {
            _presenter.Initialize();
        }
    }
 
    override protected void OnInit(EventArgs e)
    {
        base.OnInit(e);
        _presenter = new SolutionPresenter(this);
        submit.Click += delegate { _presenter.ShowTracks(); };
    }
 
    public string SelectedRecord
    {
        get { return (string)recordingSelect.SelectedItem.Value; }
    }
    
    public DataSet Recordings
    {
        set
        {
            recordingSelect.DataSource = value;
            recordingSelect.DataTextField = "title";
            recordingSelect.DataValueField = "id";
            recordingSelect.DataBind();
        }
    }
    
    public DataSet Tracks
    {
        set
        {
            MyDataGrid.DataSource = value;
            MyDataGrid.DataBind();
        }
    }
}

Right now we have logic within the presenter, and we have been able to examination SolutionPresenter with I SolutionView individually by using Mocks.

Model-View-ViewModel

Right here once again, you will find 3 elements: model, see, as well as a 3rd part - an additional model referred to as ViewModel. This pattern is ideal for technologies, where there is a two-way Binding (synchronization) of elements to the product, as in WPF. Big difference between MVVM and MVP pattern is that for MVVM SelectedRecord property, from your previous illustration, needs to be positioned inside of the ViewModel, and it should be synchronized with the required field of see. So, this is the essential thought of ??WPF. ViewModel - it is type of tremendous converter that converts information of product to the representation, it describes the fundamental homes from the check out and the logic of conversation with the design.

 



ASP.NET Hosting - ASPHostPortal.com :: Fixing the Circular File References are Not Allowed Error in ASP.NET

clock December 16, 2014 07:18 by author Dan

Introduction

In the event that you get the "circular file references are not allowed" mistake in an ASP.NET Website Project and you don't have any controls that have any undeniable circular references, what does the blunder mean and how would you settle it? Today we will explain to fix that problem to you. By default, in a Website Project, ASP.net compiles one dll per folder in an ASP.net project. So if you have the following setup:

/folder1/Control1.ascx > References Control2
/folder2/Control2.ascx > References Control3
/folder1/Control3.ascx

This means that the folder1 dll will reference the folder2 dll which will again reference the folder1 dll, causing a “circular file reference”.

Regardless of the fact that there is not an immediate way between the controls, circular reference, yet there is an immediate way joining the circular reference through different controls in the same indexes, it can toss the circular record references blunder. Case in point:

/folder1/Control1.ascx > References /folder2/Control2a.ascx
/folder2/Control2b.ascx > References /folder1/Control3.ascx
/folder1/Control3.ascx

Steps to fix it:

>> Adjust the format of your controls (or masterpages) to uproot the round references (typically this will mean moving one control to an alternate envelope – in the case above, move control2 to folder1). This is the favored arrangement.
>> Use batch="false" in the assemblage tag of the web.config document. This will result in another dll to be made for each one control/page in the site. This ought to settle the blunder however is truly lousy for execution, so it ought to be kept away from (particularly on creation locales.

Hopefully this article can help you to fix your ASP.NET problem.



ASPHostPortal.com Proudly Launches ASP.NET 5 Hosting

clock December 10, 2014 05:42 by author Dan

ASPHostPortal.com, The Best, Cheap and Recommended ASP.NET Hosting proudly announced the availability of ASP.NET 5 Hosting in their hosting deals. ASPHostPortal offer ASP.NET 5 Hosting at affordable price, easy and instant setup, and best customer support.

Finally, the long awaited release of ASP.NET 5, ASPHostPortal are happy to announce the availability of the .NET Framework 5 for all our hosting packages. It is a highly compatible, in-place update to the .NET Framework 4, 4.5 and 4.5.2. ASP.NET 5 has been re-imagined from the ground up to provide a faster development experience, best in class performance, full side-by-side support.

ASP.NET 5 is clean and free of bugs and is a composable .NET stack for building modern web applications for both cloud and on-premises servers. ASP.NET 5, with the help of Visual Studio 2015, lets you create modern web applications. Modern web applications not only target all devices, including PCs, Macs, Tablets and smartphones, but also work with any browser or operating system.

ASP.NET 5 gives you greater flexibility by being able to run on three runtimes:

Full .NET CLR

The full .NET CLR is the default runtime for projects in Visual Studio. It provides the entire API set and is your best option for backwards compatibility.

Core CLR (cloud-optimized runtime)

The Core CLR is a lean and completely modular runtime for ASP.NET 5 projects. This CLR has been re-designed into components so you have the flexibility to include only those features that you need in your app. You add the components as NuGet packages. When you are finished, your app is dependent only on required features. By re-factoring the runtime into separate components, we can deliver improvements to the components more quickly because each component is updated on its own schedule. The Core CLR is about 11 megabytes instead of around 200 megabytes for the full .NET CLR. The Core CLR can be deployed with your app and different versions of the Core CLR can run side-by-side (both of these advantages are described in greater detail below).

Cross-Platform CLR

Microsoft will release a cross-platform runtime for Linux and Mac OS X. When released, this runtime will enable you to develop and run .NET apps on Mac and Linux devices. They will work closely with the Mono community on this effort. Until its release, you can use the Mono CLR for cross-platform development.

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. With the ASP.NET 5 in their hosting deal will make ASPHostPortal continue to be the Best ASP.NET hosting providers. To learn more about ASP.NET 5 Hosting, please visit http://asphostportal.com/ASPNET-5-Hosting.

About ASPHostPortal.com :

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. ASPHostPortal.com has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, .NET 4.5.2/ASP.NET 4.5.1, ASP.NET MVC 6.0/5.2, Silverlight 5 and Visual Studio Lightswitch. ASPHostPortal include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and architecting highly scalable solutions. ASPHostPortal.com strive to supply probably the most technologically advanced hosting solutions available to all consumers the world over. Protection, trustworthiness, and performance are on the core of hosting operations to make certain each and every website and/or software hosted is very secured and performs at the best possible level.



ASP.NET 4.5 Hosting - ASPHostPortal.com :: How to use OnClick and OnClientClick events to Prevent Double Clicking on your ASP.Net Buttons

clock December 9, 2014 04:46 by author Dan

While ASP.NET gives a great validator set of controls, now and then you have to "move your own" so to talk when making your controls. What's more, on the off chance that you have some AJAX preparing with your buttons in the background (for instance, sparing a record in a popup window) you run the danger of having "twofold spares" happening when the client clicks on the button and nothing happens instantly.

Having battled with this issue myself recently, it took somewhat more work than expected to get this to work legitimately. Here's the manner by which you get everything to play pleasantly together.

The first step is to wire up your code behind occasion that does your handling. In case you're doing this in C# you setup your Onclick occasion:

<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />

In case you're doing this in Vb.net, there's no compelling reason to utilize the Onclick value as a part of your button, you can go straight to the code behind, make your strategy name, and utilize the Handles pivotal word, pointing out your buttons click occasion:

Protected Void Sub btnSave_Click Handles btnSave.Click
' Code here
End Sub

The next step is to do our validation using Javascript (we’re using jQuery in here).

function validatePage()
{
    var check = true;

    // Check only simple textbox for now
    if ($("#txtImportant").val() == '') check = false;

    if (!check)
    {
       alert('Missing data. Please complete');
       return false;
    }
    else
    {
       $("#MainContent_btnSave").val('Processing...');
       $("#MainContent_btnSave").attr("disabled", true);
       return true;
    }
}

There are several vital notes to this capacity. The main is not to overlook that Asp.net as a matter of course likes to help particularly name your server controls, subsequently the "Maincontent_" prefix on our spare button. You can utilize the Clientidmode property in the event that you have to get around this. The following is that we keep the client from twofold clicking the spare catch by handicapping the catch and transforming its content to say "Handling… " Finally, we just debilitate the button if the acceptance succeeds. This keeps us from needing to handicap and re-empower the button focused around the results. Strangely it likewise verifies that our return value in the HTML component forms accurately, which was likely one of the greatest glitches I ran crosswise over amid this process.

Presently we have to wire up the Javascript handling. To do this, we utilize the Onclientclick technique that is accessible for most .Net server controls. While taking a gander at our code above looks clear enough (return false to prematurely end the script or valid to proceed with the post back) we do need to change our rationale somewhat. Having a "return genuine" explanation doesn't let the button proceed with its post back, it will make it quit handling (very nearly the same as a return false summon). Rather, we let our rationale just prematurely end if our acceptance fizzled:

<asp:Button ID="btnSave" runat="server"
            Text="Save"
            OnClick="btnSave_Click"
            OnClientClick="if (!validatePage()) {return false;}" />

At long last, following we're overriding the HTML onclick occasion on the control (on account of the Oncilentclick property) that regardless of the possibility that your acceptance strategy succeeds, the code behind system won't shoot. To work around this, we utilize the Usesubmitbehavior property of the button control and set it to false. What this does is attaches the suitable __dopostback call after our Javascript code. The last code for your button resembles this:

<asp:Button ID="btnSave" runat="server"
            Text="Save"
            OnClick="btnSave_Click"
            OnClientClick="if (!validatePage()) {return false;}"
            UseSubmitBehavior="false" />

That is all there is to it. Presently when you click on the button, if the acceptance falls flat, you'll get the caution box. Something else, the button will get to be crippled with a "handling" message and your code behind strategy will run.



ASP.NET 4.5 Hosting - ASPHostPortal.com :: Uploading Several Data files Employing jQuery and Generic Handler in ASP.NET 4.5

clock December 5, 2014 09:11 by author Ben

This post describes the best way to upload numerous data files in ASP.NET Kinds using the jQuery and Generic Handler. Generally builders utilize the FileUpload Server management to add data files from the client device for the server that's rendered as as an Enter factor and set to file and helps you to pick out the file or various information. We can easily make use of the jQuery to help make an Ajax connect with towards the server and Submit the many picked documents for the Generic Handler as opposed to an entire webpage postback.

 


On this short article for creating the application, I am utilizing Visual Studio 2013 that has the framework 4.5.1. So, let us start with all the following course of action.

Creating WebForms

Step 1: Open Visual Studio and create the ASP.NET Web Application.

Step 2: Select the WebForms project template to proceed.

Visual Studio automatically creates the project and adds files and folders to the project by default.

Creating WebForm


Step 1: Just right-click on the project and add a new folder named "UploadedFiles".


Step 2: Just right-click on the project and add a new Web Form and replace the body content from the following content:

<form id="form1" runat="server">

    <h2>ASP.NET</h2>
    <p class="lead">Selcting Multiple Files using jQuery and Generic Handler</p>  

 

    <div class="form-group">
        <div>
            <asp:Label runat="server" AssociatedControlID="MultipleFilesUpload">Select Files</asp:Label>           
            <asp:FileUpload ID="MultipleFilesUpload" runat="server" AllowMultiple="true" />          

        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <asp:Button runat="server" ID="BtnUpload" Text="Upload Files" CssClass="btn btn-default" />
        </div>
    </div>  
 </form>


In the code above, I used the AllowMultiple property of FileUpload that is set to true. It is one of the HTML 5 features used in here.

Step 2: Now in the <head> section add the following code:

<script src="Scripts/jquery-1.10.2.js"></script>

<link href="Content/bootstrap.css" rel="stylesheet" />

<link href="Content/Site.css" rel="stylesheet" />

<script type="text/javascript">
    $(document).ready(function () {
        $("#BtnUpload").click(function (event) {
            var uploadfiles = $("#MultipleFilesUpload").get(0);
            var uploadedfiles = uploadfiles.files;
            var fromdata = new FormData();
            for (var i = 0; i < uploadedfiles.length; i++) {
                fromdata.append(uploadedfiles[i].name, uploadedfiles[i]);
            }
             var choice = {};
            choice.url = "UploadHandler.ashx";
            choice.type = "POST";
            choice.data = fromdata;
            choice.contentType = false;
            choice.processData = false;
            choice.success = function (result) { alert(result); };
            choice.error = function (err) { alert(err.statusText); };
            $.ajax(choice);
            event.preventDefault();
        });
    });
</script>

Via the code over, the data files are chosen inside the file upload handle working with the information residence of the DOM factor. the loop iterates by means of many of the information then calls the append() method of the FormData to incorporate the data files into the FormData item.

Now, the info is usually to be sent into the server. The £.ajax() is employed to transfer the information. The choice item supplies numerous options such as focus on URL and HTTP process. Now we have set the URL home on the GenericHandler file named UploadHandler.ashx . We now have established the contentType and processData home to phony with which the jQuery will not likely URL encode the info while sending into the server. The achievements and mistake properties are utilised to display the messages as a result of an warn.

Creating Generic Handler

Step 1: Add the Generic Handler by right-clicking on the project named UploadHandler.


Step 2: Modify the code with the following code:

namespace UploadMultipleFilesApp
{
    public class UploadHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.Files.Count > 0)
            {
                HttpFileCollection SelectedFiles = context.Request.Files;
                for (int i = 0; i < SelectedFiles.Count; i++)
                {
                    HttpPostedFile PostedFile = SelectedFiles[i];
                    string FileName = context.Server.MapPath("~/UploadedFiles/" + PostedFile.FileName);
                    PostedFile.SaveAs(FileName);                   
                }
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("Please Select Files");
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write("Files Uploaded Successfully!!");
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

In this article we will see which the information which might be posted to your server and will be accessed using the Ask for object. Each individual element in the HttpFileCollection is of type HttpPostedFile. FileName property is utilized to receive the file identify of posted file and return it and also the similar name id used to conserve the file.

Run WebForm

Now run the webform and choose the files as shown below that the files are selected.


After clicking on Upload Files, the message is generated.


Summary

This article explained the best way to choose numerous information and add them utilizing jQuery and Generic Handler in ASP.NET Web Forms. Joyful Coding and thanks for looking at.

 



Cheap ASP.NET 4.5 Hosting

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


 

Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Tag cloud

Sign in