European ASP.NET 4.5 Hosting BLOG

BLOG about ASP.NET 4, ASP.NET 4.5 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

ASP.NET 4.6 Hosting Portugal - HostForLIFE.eu :: How to Use Script to Disable Auto Fill TextBoxes in Some Browsers

clock September 26, 2015 12:59 by author Rebecca

Recent's browsers like Chrome, Firefox, Internet Explorer and Safari has functionality of auto complete values in TextBoxes. If you have enabled this features in browser, every time you start to enter value in TextBox you get a drop down of prefilled values in that TextBox. This feature of browser can be disabled by the programming for a specific web form like payment form and other confidential information form of a web application.

In chrome browser, you can enable auto-fill as shown below:

Step 1

Then you will have a below form for online payment of product by credit card or debit card then it is mandatory to stop auto complete functionality of browser so that browser doesn’t save the confidential information of a customer’s credit card or debit card.

 

Step 2


Then, you can turn off auto-fill for your complete form by setting autocomplete attribute value to off as shown below:

<form id="Form1" method="post" runat="server" autocomplete="off">

 .

 .

</form>

Step 3

You can also turn off auto-fill for a particular TextBox by setting autocomplete attribute value to off as shown below:

<asp:TextBox Runat="server" ID="txtConfidential" autocomplete="off"></asp:TextBox>

Step 4

And you can also do this from code behind also like as:

txtConfidential.Attributes.Add("autocomplete", "off");

After doing one of above code you will see that there is no auto-fill.


HostForLIFE.eu ASP.NET 4.6 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



ASP.NET 4.6 Hosting UK - HostForLIFE.eu :: How to Use ASP.NET to Populate AJAX Control

clock September 17, 2015 12:03 by author Rebecca

The DynamicPopulate Control in the ASP.NET AJAX can call a page method and fill the resulting value in the target control on the page without a page refresh. The method call returns a form of  HTML string that is inserted as a child of the target element. The AJAX controls  work automatically. While it's possible to call (_doPostBack()) from JavaScript to trigger for a partial update. When  we use the ASP.NET DropDownList control, ASP.NET will verify that the items in the list are the same items the list contained when the page was rendered. Since we are adding items on the client side, a postback results in an ASP.NET validation error. This postback validation is designed to prevent users from editing your web pages and trying to submit invalid data. You can disable this validation but, for our purposes, it's simpler just to use a <select> tag.

Step 1

Open Visual Studio, Go to File->New->WebSite and Select ASP.NET Empty WebSite:

Step 2

  • Go to Solution Explorer and right-click.
  • Select Add->New Item.
  • Select WebForm.
  • Default.aspx page open

Step 3

Go to Default.aspx page and click on the [Design] option and drag control from Toolbox. Then, drag Panel control, Label, Button, Drop List control, ScriptManager control.

Step 4

The page contain a button with the ID PopList. The onclick attribute of this attribute calls the PopulateList() JavaScript function.

JavaScript Function

<title>my ajax application</title>
<style type="text/css">
        body
        {
            font-family: @BatangChe
            font-size: small;
            color: #555555;
        }
    </style>
    <script type="text/javascript">
        function PopulateList() {
            PageMethods.GetListData(1, OnPopulateList);
        }
        function OnPopulateList(list) {
            var dropList = document.getElementById('DropList');
            for (i = 1; i < 10; i++) {
                var option = document.createElement('OPTION');
                option.text = list[i].text;
                option.value = list[i].value;
                dropList.options.add(option);
            }
        }
    </script>

Step 5

Go to Default.aspx[Source] option and define the condition EnablePageMethod is "True" with ScriptManager and write a code:

<form id="form1" runat="server" style="background-color: #330D1E">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True">
        </asp:ScriptManager>
        <p style="background-color: #2FC8D0">
        </p>
        <p style="background-color: #C0D1AF">
           How to populate control in ajax
        </p>
        <p style="background-color: #B8C9C9">
            <input id="PopList" type="button" value="Populate List"
                onclick="PopulateList();" style="background-color: #A5DCBD" />
        </p>
        <p style="background-color: #784847">
            <select id="DropList" name="DropListName"
                style="width: 200px; background-color: #B3CEC6;">
            </select>
        </p>
        <p style="background-color: #808080">
            <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
        </p>
        <p style="background-color: #9A96E9">
            <asp:Label ID="lblSubmitValue" runat="server" BackColor="#FFFFCC"
                BorderWidth="15px"></asp:Label>
        </p>
    </div>
    </form>

Step 6

Now we create List Data Class. The data returns a list of objects for this class. The class consist two member Text, Value.

public class ListData
        {
            public string text { get; set; }
            public int value { get; set; }
        }

Step 7

Now we define the method for Client Side JavaScript and method return the data (List Data object):

public static IEnumerable<ListData> GetListData(int arg)
        {
            List<ListData> list = new List<ListData>();
            for (int i = 0; i < 100; i++)
                list.Add(new ListData()
                {
                    text = String.Format("List Item {0}", i),
                    value = i
                });
            return list;
        }

Step 8

The collection represents the raw values being posted to the page of List Data Items. Then these data items consist of the following namespace are use it.

using System.Collections.Generic;

Step 9

Now go to the Default.aspx.cs file; write code for the method to be called from client-side JavaScript:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Form["DropListName"] != null)
                lblSubmitValue.Text = String.Format("Submitted Value: \"{0}\"",
                    Request.Form["DropListName"]);
        }
        public class ListData
        {
            public string text { get; set; }
            public int value { get; set; }
        }
        [System.Web.Services.WebMethod]
        [System.Web.Script.Services.ScriptMethod]
        public static IEnumerable<ListData> GetListData(int arg)
        {
            List<ListData> list = new List<ListData>();
            for (int i = 0; i < 100; i++)
                list.Add(new ListData()
                {
                    text = String.Format("List Item {0}", i),
                    value = i
                });
            return list;
        }
    }

Step 10

Now run the application pressing F5.

This page demonstrate how to dynamically populate a control using AJAX.

Step 11

Click on the populate list button to populate the dropdown list.

Step 12

Now click on the Submit button to submit the selected value back to the server.

Step 13

Now, you will change the dropdown list item and click on the submit button to again submit the selected value back to the server.

HostForLIFE.eu ASP.NET 4.6 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



ASP.NET 4.6 Hosting Germany - HostForLIFE.eu :: JSON Serialization and Deserialization in ASP.NET 4.6

clock September 14, 2015 06:02 by author Peter

This is all concerning JSON Parsing in ASP.NET. JSON is a info that for running JavaScript on websites. Now a days , JSON is booming on website.This code focuses on JSON serialization and Deserialization in ASP.NET 4.6. First, open your visual studio and then write the following code:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Runtime.Serialization.Json; 
using System.IO; 
using System.Text; 
using System.Text.RegularExpressions; 
/// <summary> 
/// JSON Serialization and Deserialization Class 
/// </summary> 
namespace JsonParsingSample 

public class ClassJsonHelper 

    /// <summary> 
    /// JSON Serialization Method 
    /// </summary> 
    public static string ToJsonConvertor < T > (T t) 
    { 
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T)); 
        MemoryStream ms = new MemoryStream(); 
        ser.WriteObject(ms, t); 
        string jsonString = Encoding.UTF8.GetString(ms.ToArray()); 
        ms.Close(); 
        //Replace Json Date String 
        string p = @"\\/Date\((\d+)\+\d+\)\\/"; 
        MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString); 
        Regex reg = new Regex(p); 
        jsonString = reg.Replace(jsonString, matchEvaluator); 
        return jsonString; 
    } 
    /// <summary> 
    /// JSON Deserialization Method 
    /// </summary> 
    public static T FromJsonConvertor < T > (string jsonString) 
    { 
        //Convert "yyyy-MM-dd HH:mm:ss" String as "\/Date(1319266795390+0800)\/" 
        string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}"; 
        MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate); 
        Regex reg = new Regex(p); 
        jsonString = reg.Replace(jsonString, matchEvaluator); 
        DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T)); 
        MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)); 
        T obj = (T) ser.ReadObject(ms); 
        return obj; 
    } 
    /// <summary> 
    /// Convert Serialization Time /Date(1319266795390+0530) as String 
    /// </summary> 
   private static string ConvertJsonDateToDateString(Match m) 
    { 
      string result = string.Empty; 
        DateTime dt = new DateTime(1970, 1, 1); 
        dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value)); 
        dt = dt.ToLocalTime(); 
        result = dt.ToString("yyyy-MM-dd HH:mm:ss"); 
        return result; 
    } 
    /// <summary> 
    /// Convert Date String as Json Time 
    /// </summary> 
    private static string ConvertDateStringToJsonDate(Match m) 
    { 
        string result = string.Empty; 
        DateTime dt = DateTime.Parse(m.Groups[0].Value); 
        dt = dt.ToUniversalTime(); 
        TimeSpan ts = dt - DateTime.Parse("1970-01-01"); 
        result = string.Format("\\/Date({0}+0530)\\/", ts.TotalMilliseconds); 
        return result; 
    } 

HostForLIFE.eu ASP.NET 4.6 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



HostForLIFE.eu Proudly Launches ASP.NET 4.6 Hosting

clock September 7, 2015 12:32 by author Peter

HostForLIFE.eu was established to cater to an underserved market in the hosting industry; web hosting for customers who want excellent service. HostForLIFE.eu – a cheap, constant uptime, excellent customer service, quality, and also reliable hosting provider in advanced Windows and ASP.NET technology. HostForLIFE.eu proudly announces the availability of the ASP.NET 4.6 hosting in their entire servers environment.

http://hostforlife.eu/img/logo_aspnet1.png

ASP.NET is Microsoft's dynamic website technology, enabling developers to create data-driven websites using the .NET platform and the latest version is 5 with lots of awesome features. ASP.NET 4.6 is a lean .NET stack for building modern web apps. Microsoft built it from the ground up to provide an optimized development framework for apps that are either deployed to the cloud or run on-premises. It consists of modular components with minimal overhead.

According to Microsoft officials, With the .NET Framework 4.6, you'll enjoy better performance with the new 64-bit "RyuJIT" JIT and high DPI support for WPF and Windows Forms. ASP.NET provides HTTP/2 support when running on Windows 10 and has more async task-returning APIs. There are also major updates in Visual Studio 2015 for .NET developers, many of which are built on top of the new Roslyn compiler framework. The .NET languages -- C# 6, F# 4, VB 14 -- have been updated, too.There are many great features in the .NET Framework 4.6. Some of these features, like RyuJIT and the latest GC updates, can provide improvements by just installing the .NET Framework 4.6.

HostForLIFE.eu hosts its servers in top class data centers that is located in Amsterdam (NL), London (UK), Paris (FR), Frankfurt(DE) and Seattle (US) to guarantee 99.9% network uptime. All data center feature redundancies in network connectivity, power, HVAC, security, and fire suppression. All hosting plans from HostForLIFE.eu include 24×7 support and 30 days money back guarantee. The customers can start hosting their ASP.NET 4.6 site on their environment from as just low €3.00/month only.

HostForLIFE.eu is a popular online ASP.NET based hosting service provider catering to those people who face such issues. The company has managed to build a strong client base in a very short period of time. It is known for offering ultra-fast, fully-managed and secured services in the competitive market.

HostForLIFE.eu offers the latest European ASP.NET 4.6 hosting installation to all their new and existing customers. The customers can simply deploy their ASP.NET 4.6 website via their world-class Control Panel or conventional FTP tool. HostForLIFE.eu is happy to be offering the most up to date Microsoft services and always had a great appreciation for the products that Microsoft offers.

Further information and the full range of features ASP.NET 4.6 Hosting can be viewed here http://hostforlife.eu/European-ASPNET-46-Hosting



ASP.NET 4.6 Hosting - HostForLIFE.eu :: How to Use ASP.NET and C# to Show First & Last Day in a Month

clock September 7, 2015 09:17 by author Rebecca

In this post, I'm going to show you how calculate the first day and last day of a month for one of the project. The method that I'm using is very simple.

Here is the code:

DateTime today = DateTime.Now; //current date

DateTime firstDay = today.AddDays(-(today.Day - 1)); //first day

today = today.AddMonths(1);
DateTime lastDay = today.AddDays(-(today.Day)); //last day

The Explanation

The Calculation of First Day

DateTime firstDay = today.AddDays(-(today.Day - 1));

Here I'm using the AddDays method which can add given number of days to the current date. Using today.Day I'm extracting the current date day as integer value, which is 21 in my example. The tricky part here is that I'm adding with the AddDays method total of 21-1 = 20 and using the minus sign, it's getting 20 days back (instead of 20 days forward).

The Calculation of the Last Day

today = today.AddMonths(1);
DateTime lastDay = today.AddDays(-(today.Day)); //last day

With today = today.AddMonths(1) I'm adding one month plus to the current date.
Before adding, for example the today value was {21-07-2015 17:27:50} - after adding +1 month, the today value is {21-08-2015 17:27:50}.
Then, with the last line, the trick is very similar to the firstDayDate calculation, we only go in minus to the number of days got from the today.Day integer value. We do not add today.Day-1 here because if you do, you will get the first day of the next month (so you know one more thing now, how to get the first day of the next month).
The lastDay value will be 31-07-2015 17:27:50

HostForLIFE.eu ASP.NET 4.6 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in