I’m using a button to get the IP address. I want to display that IP address in the text field.
This is my front end code:
<asp:TextBox ID="txtMachIP" runat="server" CssClass="Textbox1"></asp:TextBox>
<asp:Button ID="BtnGetIP" runat="server" CssClass="btn1"
onclick="BtnGetIP_Click" Text="Get My IP" />
This is my backend code for getting the ip:
protected void BtnGetIP_Click(object sender, EventArgs e)
{
string myHost = System.Net.Dns.GetHostName();
System.Net.IPHostEntry myIPs = System.Net.Dns.GetHostEntry(myHost);
foreach (System.Net.IPAddress myIP in myIPs.AddressList)
{
MessageBox.Show(myIP.ToString());
}
}
Instead of the message box, I want my IP to be displayed in the text area.
Please give a name to your textbox like
And in backend code