ASP.NET 4.5 Hosting BLOG

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

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.

 



ASP.NET 4.0 Hosting - ASPHostPortal.com :: How to Fix Register ASP.net 4.0 With IIS Windows Server 2012

clock December 2, 2014 10:27 by author Dan

Introduction

ASP.NET 4.0 is a version that launch after ASP.NET 3.5 version. ASP.NET is an open source server-side Web application framework designed for Web development to produce dynamic Web pages. It was developed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. Today we will discuss about "How to Fix Register ASP.net 4.0 With IIS Windows Server 2012".

Issue

Chanced upon an issue where Asp.net 4.0 wasn't enlisted with IIS running on Windows Server 2012. Prior to that Server OS the arrangement was a simple one: just take after this posting of mine and all is fine once more.
Notwithstanding, Windows Server 2012 and later don't help that any longer and the ONLY alter is evacuating IIS and reinstalling it with Asp.net 4.0. Anyway that is an excessive amount of and takes an excess of time, exertion and assets.

Quick Fix

This is the step to fix this problem WITHOUT removing and reinstalling IIS:

  • Open IIS Manager and select the webserver and select Modules (found under header IIS);
  • Double click on it, so you open Modules, and remove the module ServiceModel;
  • Go back to IIS Manager, select the webserver again in IIS, and select Handler Mappings (found under header IIS);
  • Remove the handler svc-Integrated;
  • Restart IIS by using an elevated cmd prompt and issue this command: IISRESET <enter>;
  • When IIS is running again add WCF by going to "Turn Windows Features On and Off" and enable .NET Framework 4.5 Features > WCF Services > HTTP Activation;
  • Restart IIS by using an elevated cmd prompt and issue this command: IISRESET <enter>

Now the SCOM 2012 Web Console will be fully functional WITHOUT reinstalling IIS.



ASP.NET 4.5 HOSTING - ASPHostPortal :: How to Implement a Simple Captcha in C# .NET

clock December 1, 2014 06:07 by author Mark

Implement a simple captcha in C# .NET

  • Create a page with name “Captcha.aspx
  • Place the following html code in body part of the page

IMG height="30" alt="" src=BuildCaptcha.aspx width="80">
asp:TextBox runat="Server" ID="txtCaptcha">
    <asp:Button runat="Server" ID="btnSubmit"
     OnClick="btnSubmit_Click"
       Text="Submit" />
     On “btnSubmit_Click” place the following code
         if (Page.IsValid && (txtCaptcha.Text.ToString() ==
         Session["RandomStr"].ToString()))
           {
             Response.Write("Code verification Successful");
           }
    else
{
  Response.Write( "Please enter info correctly");
}

  • Include the following code in “BuildCaptcha.aspx"

Bitmap objBMP = new Bitmap(60, 20);
Graphics objGraphics = Graphics.FromImage(objBMP);
objGraphics.Clear(Color.Wheat);
objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
  //' Configure font to use for text
      Font objFont = new Font("Arial", 8, FontStyle.Italic);
      string randomStr = "";
      char[] myArray = new char[5];
      int x;
   //That is to create the random # and add it to our string
     Random autoRand = new Random();
     for (x = 0; x < 5; x++)
{
  myArray[x] = System.Convert.ToChar(autoRand.Next(65,90));
  randomStr += (myArray[x].ToString());
}
     //This is to add the string to session, to be compared later
       Session.Add("RandomStr", randomStr);
    //' Write out the text
       objGraphics.DrawString(randomStr, objFont, Brushes.Red, 3, 3);
    //' Set the content type and return the image
  Response.ContentType = "image/GIF";
objBMP.Save(Response.OutputStream, ImageFormat.Gif);
objFont.Dispose();
objGraphics.Dispose();
objBMP.Dispose();

There you go you can test the page with captcha. Happy Programming Laughing



ASP.NET 4.5 Hosting - ASPHostPortal.com :: Add Multiple Files Utilizing ASP.NET 4.5

clock November 28, 2014 05:07 by author Ben

In earlier versions of ASP.NET (edition under ASP.NET 4.5), we didn't have any inbuilt functionality to add several files at the same time. ASP.NET FileUpload handle permits uploading just one file in a time. Alternate answers to add numerous files are third party controls like Telerik or Devexpress. We can also use various jQuery Plugin like Uploadify to attain comparable performance.


In ASP.NET 4.5, we can add multiple documents simultaneously making use of ASP.NET FileUpload control. In ASP.NET 4.5, FileUpload Control support HTML5 several attribute.

Under are the steps to add numerous information utilizing ASP.NET 4.5 :

  1. In Visual Studio 2012, In Visual Studio 2012, create a new website using .Net 4.5 framework.
  2. Add a new web form (for example FileUpload.aspx) in newly created website.
  3. In code-beside file of FileUpload.aspx, write following code for FileUpload Control:

<asp:fileupload AllowMultiple="true" id="MultipleFileUpload" runat="server">
</asp:fileupload>

In above code, I have set AllowMultiple property of FileUpload Control to true.

Add one button to upload multiple files using FileUpload Control on button click.

<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />

Write below code on button click event handler.

protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (MultipleFileUpload.HasFiles)
        {
            StringBuilder UploadedFileNames = new StringBuilder();

            foreach (HttpPostedFile uploadedFile in MultipleFileUpload.PostedFiles)
            {
                string FileName = HttpUtility.HtmlEncode(Path.GetFileName(uploadedFile.FileName));
                uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Files/"), FileName));
                UploadedFileNames.AppendFormat("{0}<br />", FileName);
            }
            Response.Write("Uploaded Files are : <br/>" + UploadedFileNames);
        }
    }

On button click, I am checking for multiple files and saving those files into Files folder of web application.
Compile source code and run the website application.

 

I had selected five images to upload. Once I had clicked on Upload button, all five images were uploaded successfully in Files folder.



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