Get IPAddress and HostName From PC or Laptop Using in Asp.Net C#

Get IPAddress and HostName From PC or Laptop

Get the IPAddress and HostName From Pc Or Laptop Button Click in Asp.Net C#.

                                     DEMO



                         Download Coding

                               Download
                         

                             HTML COIDING


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <p>
    
            <asp:Label ID="Label1" runat="server" Text="IPAddress"></asp:Label>
<asp:TextBox ID="txtIPAddress" runat="server"></asp:TextBox>
  
            <asp:Label ID="Label2" runat="server" Text="HostName"></asp:Label>
<asp:TextBox ID="txtHostName" runat="server"></asp:TextBox>
   
         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
    <div>
   
    </div>
    </form>
</body>
</html>


                               C# CODING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Net;
using System.Net.Sockets;
using System.IO;
public partial class IPGET : System.Web.UI.Page
{   
    protected void Button1_Click(object sender, EventArgs e)
    {
        GetComputer_LanIP();
    }
    protected string GetComputer_LanIP()
    {
        string HostName = System.Net.Dns.GetHostName();
        IPHostEntry ipEnt = System.Net.Dns.GetHostEntry(HostName);
        foreach (IPAddress ipAddress in ipEnt.AddressList)
        {
            if (ipAddress.AddressFamily.ToString() == "InterNetwork")
            {
                txtIPAddress.Text = ipAddress.ToString();
                txtHostName.Text = ipEnt.HostName.ToString();
                return ipAddress.ToString();
            }
        }

        return "-";
    }
}



First - Add New  - Form  - Select Label,Textbox,Button From ToolBox




Next - Add Namespaces - Network Call Ip Address for PC




Next - Run [F5] - Button Click - Show the Ip Address


Find Out PC & Laptop Power Status From in Battery Or Charging Using Asp.Net C#

Find Out PC & Laptop Power Status  in  Battery Or Charging 


Your PC or Laptop Charging From Battery or Charging in Asp.Net C#.

                                      DEMO
Charge Control Check

                       C# CODING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Management;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public partial class Battery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        PowerLineStatus status = SystemInformation.PowerStatus.PowerLineStatus;
        if (status == PowerLineStatus.Offline)
        {
            MessageBox.Show("Running on Battery");
        }
        else
        {
            MessageBox.Show("Running on Power");
        }
              
    }

}


First - Add New Web Form - Add Button From 

Toolbox





Next - Solution Explorer - Add - Add Reference 





Next - Add - System.Windows.Form - OK






Next - Add Namespaces - Add Charge Control  Status Checker






Next - Run[F5] - Click Button - Charge Control Check



Restart PC or Laptop WinForm Diagnostics Button Click Using in Asp.Net C#

Restart PC or Laptop 

Click Button Restart Your Working  PC or Laptop in WinForm Diagnostics in Asp.Net C#.




                        Download Coding
              
                                         Download


                          C# CODING


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;

public partial class Restarts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    ProcessStartInfo restart = new ProcessStartInfo("shutdown.exe", "-r");

        Process.Start(restart);

    }

}


First Add - New Webform - Select Button From 

ToolBox





Next - Add - Namespaces - using System.Diagnostics; & ShutDown.exe






Next - Run[F5] - Click Restart Button - Restart system



Shut Down PC or Laptop WinForm Diagnostics Button Click Using in Asp.Net C#

Shut Down PC or Laptop 

Click Button Shut Down Your Working  PC or Laptop in WinForm Diagnostics in Asp.Net C#.


                           
                        Download Coding
              
                                         Download


                          C# CODING


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;


public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }  
    protected void Button1_Click(object sender, EventArgs e)
    {
      
   ProcessStartInfo shutdown = new ProcessStartInfo("shutdown.exe", "-s");

        Process.Start(shutdown);

    }

}


First -  Add New Form - Select Button - From 

ToolBox 





Next - Add Namespaces - using System.Diagnostics; & shutdown.Exe





Next - Run[F5] - Click Button - Shutdown



GridView Selected Row Values in Previous Page Avoid Page Refresh (Go To Previous Page Using JavaScript) Using Back Button in JavaScript Asp.Net C#

GridView Selected Row Values in PreviousPage Avoid Page Refresh Using JavaScript Asp.Net C#.


First   Form  Select Some Gridview Rows After Go to Second Form  . Next Click Back Button - Go Back to Previous  Page Without Refreshing Gridview Rows Using JavaScript in Asp.Net C#.

Avoid page refresh in Gridview Update,Delete,Insert

Avoid page refresh in using Ajax UpdatePanel

                                          DEMO



HTML CODING Page 1

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
     <table> <tr><td </td><td> <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"  Height="150px"  Width="200px" >
            <AlternatingRowStyle BackColor="#FF9966" />
           <Columns>
               <asp:TemplateField HeaderText="SNO">
                   <ItemTemplate>
                       <asp:Label ID="Label1" runat="server" Text='<%# Eval("Sno") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:TemplateField HeaderText="NAME">
                   <ItemTemplate>
                       <asp:Label ID="Label2" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:TemplateField HeaderText="CITY">
                   <EditItemTemplate>
                       <asp:TextBox ID="txtCtyUpdate" runat="server"></asp:TextBox>
                   </EditItemTemplate>
                   <ItemTemplate>
                       <asp:Label ID="Label3" runat="server" Text='<%# Eval("City") %>'></asp:Label>
                   </ItemTemplate>
               </asp:TemplateField>
               <asp:TemplateField HeaderText="Select">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" Text="Click" />
                    </ItemTemplate>
                </asp:TemplateField>
           </Columns>
        
             <HeaderStyle BackColor="#CC3300" />
            <RowStyle BackColor="Silver" />
        
             </asp:GridView>
   
            </td></tr></table>

    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Go To Second Page" />
   
    </div>
    </form>
</body>
</html>


HTML CODING Page 1


<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>

   
    <script type="text/javascript">
        function goBack() {
            window.history.back();
        }
</script>


</head>
<body>
    <form id="form1" runat="server">
    <div>  
            
 <asp:Button ID="Button5" runat="server" Text="Back" OnClientClick="history.back(-1)"/>
      
                </div>
    </form>
</body>
</html>


                            C# CODING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class RemoveRow : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }
    protected void Bind()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Sno", typeof(string));
        dt.Columns.Add("Name", typeof(string));
        dt.Columns.Add("City", typeof(string));

       
        dt.Rows.Add("1", "AAA", "Mumbai");
        dt.Rows.Add("2", "BBB", "New Delhi");
        dt.Rows.Add("3", "CCC", "Kolkata");
        //dt.Rows.Add("4", "DDD", "Chennai");
        //dt.Rows.Add("5", "EEE", "Bangalore");


        Session["Detail"] = dt;
        DataTable dt1 = (DataTable)Session["Detail"];
      
        GridView2.DataSource = dt;
        GridView2.DataBind();
    }       
  
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("SendMail.aspx");
    }
}


First - Add GridView  - Bind Data Fields Temporery From ToolBox - Add Button For Next Page






Next - Add Another New Form - Button Added For Back Button






Next - Add - Script For Parent History Call






Next - First Form - Coding For GridView 





Next- F5[Run]  - Select Gridview Values - Send Another Page - Back To Previous Page