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 Hosting UK - HostForLIFE.eu :: Create the Databound Controls in ASP.NET

clock June 19, 2015 07:00 by author Peter

In this article we'll study about Databound Controls in ASP.NET. Databound controls are used to display data to the end-user inside the web applications and victimisation databound controls permits you to control the info inside the web applications very simply. Databound controls are bound to the DataSource property. Databound controls area unit composite controls that combine other ASP.NET Controls like Text boxes, Radio buttons, Buttons and so on.

Frequently used Databound controls:

  • Repeater
  • DataList
  • GridView
  • List View
  • Form View
  • Repeater

Employee.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DataReapterDemo.aspx.cs" Inherits="DataReapterDemo" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html 
xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title></title> 
<style> 
tr { 
height:40px; 

</style> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
<center> 
<div style="  border: 2px solid red;text-align: left;border-radius: 2px;Padding-top: 3px;background-color: Lime;width: 500px;border-radius: 8px;font-size: 20px;"> 
<asp:Repeater ID="rp1" runat="server"> 
<HeaderTemplate> 
<table  style="width:500px;padding-top:0px;Background-color:Gold" > 
<tr> 
    <td style="font-size: 26px; 
text-align: center; 
height: 48px;"> 
        <asp:Label ID="lblhdr" runat="server" Text = "Student Profile"></asp:Label> 
    </td> 
</tr> 
</table> 
</HeaderTemplate> 
<ItemTemplate> 
<table style="width:500px;"> 
<tr> 
    <td> 
        <asp:Label ID="lblempid1" runat="server" Text="Employee ID:"></asp:Label> 
    </td> 
    <td> 
        <asp:Label ID="lblempid2" runat="server" Text='<%# Eval("EmpId") %>'> 
        </asp:Label> 
    </td> 
    <td rowspan="5"> 
        <asp:Image ID="img1" runat="server" Width="100px" ImageUrl= ' 
            <%#"~/images/" + Eval("EmpImage")   %>'/> 
        </td> 
    </tr> 
    <tr> 
        <td> 
            <asp:Label ID="lblempname1" runat="server" Text="Employee Name"></asp:Label> 
        </td> 
        <td> 
            <asp:Label ID="lblempname2" runat="server" Text='<%# Eval("EmpName") %>'> 
            </asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td> 
            <asp:Label  ID="lblempemailId1" runat="server" Text="Employee EmailId"></asp:Label> 
        </td> 
        <td> 
            <asp:Label ID="lblempemailId2" runat="server" Text='<%# Eval("EmpEmailId") %>'> 
            </asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td> 
            <asp:Label ID="lblempmob1" runat="server" Text="Mobile Number"></asp:Label> 
        </td> 
        <td> 
            <asp:Label ID="lblempmob2" runat="server" Text='<%# Eval("EmpMobileNum") %>'> 
            </asp:Label> 
        </td> 
    </tr> 
    <tr> 
        <td> 
            <asp:Label ID="lblempgen1" runat="server" Text="Gender"></asp:Label> 
        </td> 
        <td> 
            <asp:Label ID="lblempgen2" runat="server" Text='<%# Eval("EmpGender") %>'> 
            </asp:Label> 
        </td> 
    </tr> 
</table> 
</ItemTemplate> 
<FooterTemplate> 
<table> 
    <tr> 
        <td>    
        @Peter
        </td> 
    </tr> 
</table> 
</FooterTemplate> 
</asp:Repeater> 
</div> 
</center> 
</div> 
</form> 
</body> 
</html>  

Employee.aspx.cs

using System;   
using System.Web;   
using System.Web.UI;   
using System.Web.UI.WebControls;   

using System.Data.SqlClient;   
using System.Data;   
using System.Web.Configuration;   

public partial class DataReapterDemo : System.Web.UI.Page   
{   
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["myconnection"].ConnectionString);   
protected void Page_Load(object sender, EventArgs e)   
  {   
if (!IsPostBack)   
{   
Bind();   
}    }   

public void Bind()   
{   
SqlCommand cmd = new SqlCommand("select * from Employee where EmpId = 1200",con);   
SqlDataAdapter da = new SqlDataAdapter(cmd);   
DataSet ds = new DataSet();   
da.Fill(ds, "Employee");   
rp1.DataSource = ds.Tables[0];   
rp1.DataBind();   

}   
}    
  

HostForLIFE.eu ASP.NET 5 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 Hosting Russia - HostForLIFE.eu :: Insert, Update, Delete & Retrieve Operations with ASP.NET

clock June 8, 2015 07:30 by author Peter

In this short article, I will write a simple code to Insert, update, delete, and Retrieve operations. Open the new project and then write the following code:

       using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Linq; 
    using System.Text; 
    using System.Windows.Forms;        
    using System.Data.SqlClient;             //namespace for using sqlserver components                    
    namespace InsertApp 
    { 
        public partial class Form1 : Form 
        { 
                          public Form1() 
            { 
                InitializeComponent(); 
            } 
                  private void Form1_Load(object sender, EventArgs e) 
            { 
                Getgrid(); 
            }                  
  public void Getgrid() 
            { 
                SqlConnection con = new SqlConnection("Data Source=SQLEXPRESS; Initial Catalog=SQLDATABASE; Integrated Security=SSPI "); 
                con.Open(); 
                SqlDataAdapter da = new SqlDataAdapter("select * from employee", con); 
                DataSet ds = new DataSet(); 
                da.Fill(ds); 
                dataGridView1.DataSource = ds.Tables[0]; 
           }        
            // Method for Insert the values 
            private void btnInsert_Click(object sender, EventArgs e)  
            { 
                SqlConnection con=new SqlConnection("Data Source=SQLEXPRESS; Initial Catalog=SQLDATABASE; Integrated Security=SSPI "); 
                con.Open();        
                    SqlCommand cmd = new SqlCommand("Insert into employee values('" + txtId.Text + "','" + txtName.Text + "','" + txtDesigid.Text + "','" + txtEmploc.Text + "')", con); 
                    int check = cmd.ExecuteNonQuery(); 
                    if (check > 0) 
                    { 
                        MessageBox.Show("Inserted"); 
                    } 
                    else 
                    { 
                        MessageBox.Show("Not- Inserted"); 
                    }                      
                    cmd.Dispose(); 
                    con.Close(); 
                    Getgrid();                    
            }        
            // Method for Update the values 
           private void btnUpdate_Click(object sender, EventArgs e) 
            { 
                SqlConnection con = new SqlConnection("Data Source=SQLEXPRESS; Initial Catalog=SQLDATABASE; Integrated Security=SSPI "); 
                con.Open();                    
                    SqlCommand cmd = new SqlCommand("update employee set emp_id='" + txtId.Text + "', emp_name='" + txtName.Text + "',desig_id='" + txtDesigid.Text + "',emp_location='" + txtEmploc.Text + "' where emp_id='"+txtId.Text+"'", con); 
                    cmd.ExecuteNonQuery(); 
                    MessageBox.Show("updated"); 
                    cmd.Dispose(); 
                    con.Close(); 
                    Getgrid(); 
            }        
            // Method for Delete the values 
            private void btnDelete_Click(object sender, EventArgs e) 
            { 
                SqlConnection con = new SqlConnection("Data Source=SQLEXPRESS; Initial Catalog=SQLDATABASE; Integrated Security=SSPI "); 
                con.Open();       
                SqlCommand cmd = new SqlCommand("delete from employee where emp_id='" + txtId.Text + "'", con); 
                cmd.ExecuteNonQuery(); 
                MessageBox.Show("deleted"); 
                cmd.Dispose(); 
                con.Close(); 
                Getgrid(); 
            }        
            // Method for Retrieve the values 
            private void btnRetrieve_Click(object sender, EventArgs e) 
            { 
                SqlConnection con = new SqlConnection("Data Source=SQLEXPRESS; Initial Catalog=SQLDATABASE; Integrated Security=SSPI "); 
                con.Open(); 
                      SqlCommand cmd = new SqlCommand("select * from employee where emp_id='" + txtId.Text + "'", con); 
                SqlDataReader dr = cmd.ExecuteReader(); 
                if (dr.Read()) 
                { 
                    txtId.Text = dr[0].ToString(); 
                    txtName.Text = dr[1].ToString(); 
                    txtDesigid.Text = dr[2].ToString(); 
                    txtEmploc.Text = dr[3].ToString(); 
                } 
            }        
            // Method for Clear values in textbox 
            private void btnClear_Click(object sender, EventArgs e) 
            { 
                clearmethod();             // calling clear method 
            }        
            public void clearmethod() 
            { 
                txtId.Text = ""; 
                txtName.Text = ""; 
                txtDesigid.Text = ""; 
                txtEmploc.Text = ""; 
            }      
        } 
   } 
Happy coding! 

HostForLIFE.eu ASP.NET 5 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 Drupal 7.37 Hosting

clock June 1, 2015 09:29 by author Peter

European Windows and ASP.NET Spotlight Hosting Partner in Europe, HostForLIFE.eu, has announced the availability of new hosting plans that are optimized for the latest update of the Drupal 7.37 hosting technology.

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 our Drupal site on our environment from as just low €3.00/month only.

Drupal is an open source content management platform powering millions of websites and applications. Thousands of add-on modules and designs let you build any site you can imagine. Drupal 7.37 Includes bug fixes and small API/feature improvements only (no major new functionality); major, non-backwards-compatible new features are only being added to the forthcoming Drupal 8.0 release. If you are looking for the right Windows ASP.NET Hosting provider that support Drupal 7.37, we are the right choice for you.

The 7.37 update also includes fixed a regression in Drupal 7.36 which caused certain kinds of content types to become disabled if we were defined by a no-longer-enabled module, removed a confusing description regarding automatic time zone detection from the user account form (minor UI and data structure change), allowed custom HTML tags with a dash in the name to pass through filter_xss() when specified in the list of allowed tags, allowed hook_field_schema() implementations to specify indexes for fields based on a fixed-length column prefix (rather than the entire column), as was already allowed in hook_schema() implementations, fixed PDO exceptions on PostgreSQL when accessing invalid entity URLs, added a sites/all/libraries folder to the codebase, with instructions for using it and added a description to the "Administer text formats and filters" permission on the Permissions page (string change).

HostForLIFE have hosted large numbers of websites and blogs until now. Our clients come from diverse backgrounds from all sectors of the economy. HostForLIFE.eu clients are specialized in providing supports for Drupal for many years. We are glad to provide support for European Drupal 7.37 hosting users with advices and troubleshooting for our client website when necessary.

HostForLIFE.eu is a popular online Windows 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. Our powerful servers are especially optimized and ensure Drupal 7.37 performance. We have best data centers on three continent, unique account isolation for security, and 24/7 proactive uptime monitoring.

For more information about this new product, please visit http://hostforlife.eu/European-Drupal-737-Hosting

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

HostForLIFE.eu is awarded Top No#1 SPOTLIGHT Recommended Hosting Partner by Microsoft (see http://www.asp.net/hosting/hostingprovider/details/953). Our service is ranked the highest top #1 spot in several European countries, such as: Germany, Italy, Netherlands, France, Belgium, United Kingdom, Sweden, Finland, Switzerland and other European countries. Besides this award, we have also won several awards from reputable organizations in the hosting industry and the detail can be found on our official website.



Free ASP.NET 5 Hosting - HostForLIFE.eu :: Create MD5 encryptions in ASP.NET using C#

clock May 29, 2015 07:48 by author Peter

In the world of network encryption is one of the very important idea to secure your users' information from outside hackers. usually once user input any password related field  its getting encrypted and so put that encrypted password into database. And within the case of retrieving there are 2 process are there.  You will encrypt the imputing password and match it with the field in database otherwise you can decrypt the keep password and match it with the input. I thing first one is much better and less time consuming.

So, how to encrypt your inputted password field. The most common encryption technique is MD5. Here in this example I'll show you ways to encrypt a string into an encrypted password using MD5 in ASP.NET using C#. Create a new project and add a new WebForm to start your encrypted application. in the ASPX page add a new TextBox. Create a TextChange event and on the AutoPostBack property of the TextBox.

Write the following code, in the ASPX page:
<form id="form1" runat="server">
    <div>
        <asp:textbox autopostback="True" id="TextBox1" ontextchanged="TextBox1_TextChanged" runat="server"></asp:textbox>
        Encrypted password :
        <asp:label id="Label1" runat="server" text=""></asp:label>
    </div>
</form>

Write the following code In the C# page:
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Security.Cryptography;
using System.Text;
using System;
namespace md5
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            Byte[] ePass;
            UTF8Encoding encoder = new UTF8Encoding();
            ePass = md5Hasher.ComputeHash(encoder.GetBytes(TextBox1.Text));
            Label1.Text = Convert.ToBase64String(ePass);
        }
    }
}

In the Label1 you'll see the encrypted password. simply place the ePass into the database to store as an encrypted password. Your encryption is over. I hope it works for you!

Free ASP.NET 5 Hosting
Try our Free ASP.NET 5 Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Free ASP.NET 5 Hosting - HostForLIFE.eu :: How to Make an Instant Search of Grid View in ASP.NET using C# ?

clock May 25, 2015 07:48 by author Peter

Today I'll show you the way to make a search in GridView  in ASP.NET using C#. You'll do it normally getting a ASP command button and run a query to get the value in a GridView. It'll refresh the page every time. You'll stop this by adding an UpdatePanel but the time taking will be more or less same. however here I'll use quickseacrch.js to search within a GridView. To do this produce a new project and add a new web form in your Visual Studio. In the aspx file write the following code to proceed.

<form id="form1" runat="server">
<asp:gridview autogeneratecolumns="False" headerstyle-backcolor="#3AC0F2" headerstyle-forecolor="White" id="GridView1" ondatabound="OnDataBound" runat="server">
        <columns>            
            <asp:templatefield headertext="Name">
                <itemtemplate>
                    <asp:label id="Label1" runat="server" text="<%# Eval("Name") %>"></asp:label>
                </itemtemplate>
            </asp:templatefield>            
        </columns>  
    </asp:gridview>    
    <script type="text/javascript">
        $(function () {
            $('.search_textbox').each(function (i) {
                $(this).quicksearch("[id*=GridView1] tr:not(:has(th))", {
                    'testQuery': function (query, txt, row) {
                        return $(row).children(":eq(" + i + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;                   
}
                });
            });
        });
    </script>
    </form>


Now, in the head section add a script tag to do this js function:
<script type="text/javascript">
 $(function () {
  $('.search_textbox').each(function (i) {
   $(this).quicksearch("[id*=GridView1] tr:not(:has(th))", {
    'testQuery': function (query, txt, row) {
     return $(row).children(":eq(" + i + ")").text().toLowerCase().indexOf(query[0].toLowerCase()) != -1;
    }
   });
  });
 });
</script>


In the CS page write the following code:
protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            DataTable dt = new DataTable();
            dt.Columns.AddRange(new DataColumn[1] {new DataColumn("Name", typeof(string))});
            dt.Rows.Add("Peter");
            dt.Rows.Add("Scott");
            dt.Rows.Add("Rebecca");
            dt.Rows.Add("Suzan");
            dt.Rows.Add("Tom");
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
     protected void OnDataBound(object sender, EventArgs e)
    {
        GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
        for (int i = 0; i < GridView1.Columns.Count; i++)
        {
            TableHeaderCell cell = new TableHeaderCell();
            TextBox txtSearch = new TextBox();
            txtSearch.Attributes["placeholder"] = GridView1.Columns[i].HeaderText;
            txtSearch.CssClass = "search_textbox";
            cell.Controls.Add(txtSearch);
            row.Controls.Add(cell);
        }
        GridView1.HeaderRow.Parent.Controls.AddAt(1, row);
    }


Finally, run the code. Hope it works!

Free ASP.NET 5 Hosting
Try our Free ASP.NET 5 Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Free ASP.NET 5 Hosting - HostForLIFE.eu :: How to get all file names in a folder using C#/VB.NET in ASP.NET?

clock May 22, 2015 07:59 by author Peter

Today, I am going to tell you about ASP.NET How to get all file names in a folder using C#/VB.NET. Fisrt, create the new ASP.NET project and then write the following code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class GetAllFileNames : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string str = string.Empty;
        str = str + "<ul>";
        DirectoryInfo d = new DirectoryInfo(@"D:\TextFiles");//Assuming Test is your Folder
        FileInfo[] Files = d.GetFiles("*.*"); //Getting Text files
        foreach (FileInfo file in Files)
        {
            str = str+"<li>"  + file.Name;       
        }
        str = str + "</li></ul>";
        Response.Write(str);
    }
}

VB:
Imports System.Collections.Generic
Imports System.Linq
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.IO
Partial Public Class GetAllFileNames
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim str As String = String.Empty
        str = str & "<ul>"
        Dim d As New DirectoryInfo("D:\TextFiles")
        'Assuming Test is your Folder
        Dim Files As FileInfo() = d.GetFiles("*.*")
        'Getting Text files
        For Each file As FileInfo In Files
            str = str & "<li>" & file.Name
        Next
        str = str & "</li></ul>"
        Response.Write(str)
    End Sub
End Class

And here is the output from the above code:

 

Free ASP.NET 5 Hosting
Try our Free ASP.NET 5 Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Free ASP.NET 5 Hosting - HostForLIFE.eu :: How to Move DataGrid Row Up/Down with Sorting?

clock May 18, 2015 07:11 by author Peter

In this short article, let me show you how to create two buttons "one for UP" and "one for DOWN" in the datagrid then you can easily move row up and down by using the following code.

Add code in Default.aspx page:
<asp:DataGrid ID="dgrdAdmin" runat="server" OnItemCommand="dgrdAdmin_ItemCommand"     AllowSorting="true">
     <Columns>
        <asp:BoundColumn DataField="id" Visible="false"></asp:BoundColumn>
           <asp:TemplateColumn>
              <ItemTemplate>
                 <asp:ImageButton ID="imgbtnUP" runat="server" CommandName="Up" />
                  <asp:ImageButton ID="imgbtnDown" runat="server" CommandName="Down" />
             </ItemTemplate>
          </asp:TemplateColumn>
      </Columns>
  </asp:DataGrid>

Now, write the following code:
 private int GetMaxSortOrder()
   {
      int max = 0;
      DataTable dt = new DataTable();
      SqlConnection conn = new SqlConnection("Your_Connection_String");
      SqlCommand cmd = new SqlCommand("SELECT MAX(SORTORDER) FROM Your_Admin_Table");
      conn.Open();
      SqlDataAdapter sqad = new SqlDataAdapter(cmd);
      sqad.Fill(dt);
      if (dt.Rows.Count > 0)
      {
          if (dt.Rows[0][0].ToString() != "")
          max = Convert.ToInt32(dt.Rows[0][0]);
      }
    return max;
    }
protected void dgrdAdmin_ItemCommand(object sender, DataGridCommandEventArgs e)
{
   if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
       if (e.CommandName.Equals("Up"))
       {
          int SortOrder = 0;
          SqlConnection conn = new SqlConnection("Your_Connection_String");
           if (e.Item.Cells[10].Text != "")
            {
              SortOrder = Convert.ToInt32(e.Item.Cells[10].Text);
              if (SortOrder == 0)
                {
                  DataTable dt = new DataTable();
                  SqlCommand cmd = new SqlCommand("SELECT id FROM Your_ADMIN_Table");
                  conn.Open();
                  SqlDataAdapter sqad = new SqlDataAdapter(cmd);
                  sqad.Fill(dt);
                  if (dt.Rows.Count > 0)
                  {
                    int count = 0;
                    foreach (DataRow dr in dt.Rows)
                    {                   
                    count++;
                     SqlCommand cmdUp = new SqlCommand("UPDATE Your_ADMIN_Table SET
                                        SortOrder='" + count + "' WHERE id='" + dr["id"].ToString() + "'");
                     cmdUp.ExecuteNonQuery();
                    }
                  }
                   // bind your grid
                   return;
               }
            }
           if (SortOrder == GetMaxSortOrder() || SortOrder > GetMaxSortOrder())
           return;
           SqlCommand cmd2 = new SqlCommand("UPDATE Your_ADMIN_Table SET
              SortOrder='" + SortOrder + "' WHERE SortOrder='" + (SortOrder + 1) + "'");
           cmd2.ExecuteNonQuery();
           SqlCommand cmd3 = new SqlCommand("UPDATE Your_ADMIN_Table SET
           SortOrder='" + (SortOrder + 1) + "' WHERE id='" + e.Item.Cells[1].Text + "' AND                                           
           SortOrder='" + SortOrder + "'");
           cmd3.ExecuteNonQuery();
           dgrdAdmin.DataSource = // Bind data in datagrid
           dgrdAdmin.DataBind();
         }
        if (e.CommandName.Equals("Down"))
        {
          SqlConnection conn = new SqlConnection("Your_Connection_String");
          int SortOrder = 0;
          if (e.Item.Cells[10].Text != "")
           {
             SortOrder = Convert.ToInt32(e.Item.Cells[10].Text);
             if (SortOrder == 0)
             {
               DataTable dt = new DataTable();
               SqlCommand cmd = new SqlCommand("SELECT id FROM Your_ADMIN_Table");
               conn.Open();
               SqlDataAdapter sqad = new SqlDataAdapter(cmd);
               if (dt.Rows.Count > 0)
               {
                 int count = 0;
                 foreach (DataRow dr in dt.Rows)
                 {
                   count++;
                   SqlCommand cmdDown = new SqlCommand("UPDATE Your_ADMIN_Table SET
                   SortOrder='" + count + "' WHERE id='" + dr["id"].ToString() + "'");
                   cmdDown.ExecuteNonQuery();
                 }
               }
              // bind your grid
                 return;
           }
       }
       if (SortOrder == 0)
        return;
       SqlCommand cmd1 = new SqlCommand("UPDATE Your_ADMIN_Table SET SortOrder=" + SortOrder + "' WHERE SortOrder='" + (SortOrder - 1) + "'");
       cmd1.ExecuteNonQuery();
       SqlCommand cmd2 = new SqlCommand("UPDATE Your_ADMIN_Table SET SortOrder='" + (SortOrder - 1) + "' WHERE id='" + e.Item.Cells[1].Text + "'
       AND SortOrder='" + SortOrder + "'");
       cmd2.ExecuteNonQuery();
       dgrdAdmin.DataSource = // Bind data in datagrid
       dgrdAdmin.DataBind();
       }
    }
}

Now you can easily move your datagrid row up and down with sorting.

Free ASP.NET 5 Hosting

Try our Free ASP.NET 5 Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Free ASP.NET 5 Hosting - HostForLIFE.eu :: How to Open URL in New Window with Custom Height Width Example using AngularJS and ASP.NET?

clock May 11, 2015 08:12 by author Peter

In this tutorial, I will show you How to Open URL in New Window with Custom Height Width Example using AngularJS and ASP.NET 5. I using “$window.open” we will new popup browser window with custom size in AngularJS. Now, I will be able to explain how to open new browser window with custom height and width on button click using AngularJS.

Write the following code:
// Open New Child / Browser Window
$scope.openChildWindow = function () {
var left = screen.width / 2 - 200, top = screen.height / 2 – 250
$window.open('http://www.hostforlife.eu', '', "top=" + top + ",left=" + left + ",width=400,height=500")
}

This is the complete code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> How to Open URL in New Window with Custom Height Width Example using AngularJS and ASP.NET?</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
<script type="text/javascript">
var myApp = angular.module('sampleapp', [])
myApp.controller("expressionController", function ($scope,$window) {
// Open New Child / Browser Window
$scope.openChildWindow = function () {
var left = screen.width / 2 - 200, top = screen.height / 2 – 250
$window.open('http://www.hostforlife.eu', '', "top=" + top + ",left=" + left +
,width=400,height=500")
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div data-ng-app="sampleapp" data-ng-controller="expressionController">
<input type="button" value="Open Popup Window" ng-click="openChildWindow()"/> <br /><br />
</div>
</form>
</body>
</html>

 

Free ASP.NET 5 Hosting

Try our Free ASP.NET 5 Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Free ASP.NET 5 Hosting - HostForLIFE.eu :: Create a Responsive Page Using BootStrap in ASP.NET

clock May 8, 2015 07:57 by author Peter

In this article, let me show you how to create a responsive page using BootStrap in ASP.NET. First of all, you must download BootStrap from bootstrap.com. Next step, Open your Visual Studio, add your downloaded file into your project then create the index.aspx page and call your necessary files with in the head tag from that downloaded folder.

Then, write the  following code:

<head runat="server">     
    <title></title>     
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
    <script src="js/bootstrap.min.js"></script>   
    <link href="css/bootstrap.min.css" rel="stylesheet" />   
</head>  

Consider <div class="row"></div> as a new line. Whatever you want to design in a row you should design with in a <div class="row">Your design</div>. And then <div class="col-lg-12"></div>
<div class="row"> 
    <div class="col-lg-12"> 
        Your Design

       Create a Responsive Page Using BootStrap in ASP.NET
    </div> 
</div>  

Full Code Sample
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="Responsive_Website.index" %> 
    <!DOCTYPE html> 
    <html 
        xmlns="http://www.w3.org/1999/xhtml"> 
        <head runat="server"> 
            <title></title> 
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
            <script src="js/bootstrap.min.js"></script> 
            <link href="css/bootstrap.min.css" rel="stylesheet" /> 
        </head> 
        <body> 
            <form id="form1" runat="server"> 
                <div class="container"> 
                    <div class="row"> 
                        <div class="col-lg-3"></div> 
                        <div class="col-lg-6"> 
                            <form class="form-signin"> 
                                <h2 class="form-signin-heading">Please sign in</h2> 
                                <label for="inputEmail" class="sr-only">Email address</label> 
                                <input type="email" id="inputEmail" class="form-control" placeholder="Email
ddress" required autofocus> 
                                    <label for="inputPassword" class="sr-only">Password</label> 
                                    <input type="password" id="inputPassword" class="form-control"
laceholder="Password" required> 
                                        <div class="checkbox"> 
                                            <label> 
                                                <input type="checkbox" value="remember-me">   
                                                    Remember me  
                                            </label> 
                                        </div> 
                                    <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button> 
                            </form> 
                        </div> 
                        <div class="col-lg-3"></div> 
                    </div> 
                </div> 
            </form> 
        </body> 
    </html>  

And here is the output from the above code:

Output (on small screens)

Free ASP.NET Hosting

Try our Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.



Free ASP.NET Hosting - HostForLIFE.eu :: Using the MathCap for ASP.NET 5

clock May 4, 2015 08:41 by author Peter

In this post, I will tell you about using the MathCap for ASP.NET 5. MathCap is a plugin for ASP.NET application and its a 100% effective and simple to use. The more you see on a profound look. Here i imparted is the base form of Mathcap 1.0.0. More highlight are going ahead a newer versions. And now you must add mathcapp dll reference.

Remove the namespace on the webpage using MathCapcha;
Now write the following code
var bitmapImage = new Capcha();
var properties = new MathCapchaProperties();

Now, it is time to customise the properties.

Now get the response and point to image control, using below code:
var imgur = bitmapImage.CreateThumbnail(properties);
img.Src = imgur.bmpImageSource;
Response.Write(imgur.answer);

And here is the output:

Free ASP.NET Hosting
Try our Free ASP.NET Hosting today and your account will be setup soon! You can also take advantage of our Windows & ASP.NET Hosting support with Unlimited Domain, Unlimited Bandwidth, Unlimited Disk Space, etc.

 



About HostForLIFE

HostForLIFE 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 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Month List

Tag cloud

Sign in