Aug 12

You have an IP address that you need to resolve into a hostname.

Use the Dns.GetHostEntry method to get the hostname for an IP address. In the following code, an IP address is resolved, and the hostname is accessible from the HostName property of the IPHostEntry:

 using System;
using System.Net;

//…
// Use the Dns class to resolve the address.
IPHostEntry iphost = Dns.GetHostEntry("127.0.0.1");

// HostName property holds the hostname.
string hostName = iphost.HostName;

// Print out name.
Console.WriteLine(hostName);

This article has been posted at new york dating site architect providing free online dating service.
Surprises never cease so as the growth of our online dating site, which has been on rampage.
Aug 12

You have a string representation of a host (such as www.google.com ), and you need to obtain the IP address from this hostname.

   using System;
using System.Collections.Generic;
using System.Text;
using System.Net;

namespace ConsoleApplication1
{
  class Program
  {
      static void Main(string[] args)
      {
          Console.WriteLine(HostName2IP("www.google.com"));
          Console.Read();
      }
      public static string HostName2IP(string hostname)
      {
          // Resolve the hostname into an iphost entry using the Dns class.
          IPHostEntry iphost = System.Net.Dns.GetHostEntry(hostname);
          // Get all of the possible IP addresses for this hostname.
          IPAddress[] addresses = iphost.AddressList;
          // Make a text representation of the list.

          StringBuilder addressList = new StringBuilder();
          // Get each IP address.
          foreach (IPAddress address in addresses)
          {
              // Append it to the list.
              addressList.AppendFormat("IP Address: {0};", address.ToString());
          }
          return addressList.ToString();
      }
  }
}

This article has been posted at new york dating site architect providing free online dating
service. Surprises never cease so as the growth of our online dating site, which has been
on ramapage.
Aug 12

This article has been posted at new york dating site architect providing free online dating service. Surprises never cease so as the growth of our online dating site, which has been on ramapage.

You need to get the HTML returned from a web server in order to examine it for items of interest. For example, you could examine the returned HTML for links to other pages or for headlines from a news site.


using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{
  class Program
  {
      static void Main(string[] args)
      {
          Console.WriteLine(GetHtmlFromUrl("http://www.google.com"));
          Console.Read();
      }
      public static string HostName2IP(string hostname)
      {
          // Resolve the hostname into an iphost entry using the Dns class.
          IPHostEntry iphost = System.Net.Dns.GetHostEntry(hostname);
          // Get all of the possible IP addresses for this hostname.
          IPAddress[] addresses = iphost.AddressList;
          // Make a text representation of the list.

          StringBuilder addressList = new StringBuilder();
          // Get each IP address.
          foreach (IPAddress address in addresses)
          {
              // Append it to the list.
              addressList.AppendFormat("IP Address: {0};", address.ToString());
          }
          return addressList.ToString();
      }
      public static string GetHtmlFromUrl(string url)
      {
          if (string.IsNullOrEmpty(url))
              throw new ArgumentNullException("url", "Parameter is null or empty");

          string html = "";
          HttpWebRequest request = GenerateHttpWebRequest(url);
          using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
          {

              // Get the response stream.
              Stream responseStream = response.GetResponseStream();
              // Use a stream reader that understands UTF8.
              using (StreamReader reader =
              new StreamReader(responseStream, Encoding.UTF8))
              {
                  html = reader.ReadToEnd();
              }

          }
          return html;
      }
      public static HttpWebRequest GenerateHttpWebRequest(string UriString)
      {
          // Get a Uri object.
          Uri Uri = new Uri(UriString);
          // Create the initial request.
          HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(Uri);
          // Return the request.
          return httpRequest;
      }
  }
}
Aug 12

This article has been posted at miami dating site architect providing free online dating service. Surprises never cease so as the growth of our online dating site, which has been on ramapage.

In previous versions of ASP.NET developers imported and used both custom server controls and user controls on a page by adding <%@ Register %> directives to the top of pages like so:

<%@ Register TagPrefix=”scott” TagName=”header” Src=”Controls/Header.ascx” %>
<%@ Register TagPrefix=”scott” TagName=”footer” Src=”Controls/Footer.ascx” %>
<%@ Register TagPrefix=”ControlVendor” Assembly=”ControlVendor” %>

<html>
<body>
<form id=”form1″ runat=”server”>
<scott:header ID=”MyHeader” runat=”server” />
</form>
</body>
</html>
Note that the first two register directives above are for user-controls (implemented in .ascx files), while the last is for a custom control compiled into an assembly .dll file. Once registered developers could then declare these controls anywhere on the page using the tagprefix and tagnames configured.

This works fine, but can be a pain to manage when you want to have controls used across lots of pages within your site (especially if you ever move your .ascx files and need to update all of the registration declarations.
Solution:
ASP.NET 2.0 makes control declarations much cleaner and easier to manage. Instead of duplicating them on all your pages, just declare them once within the new pages->controls section with the web.config file of your application:

<?xml version=”1.0″?>

<configuration>

<system.web>

<pages>
<controls>
<add tagPrefix=”scottgu” src=”~/Controls/Header.ascx” tagName=”header”/>
<add tagPrefix=”scottgu” src=”~/Controls/Footer.ascx” tagName=”footer”/>
<add tagPrefix=”ControlVendor” assembly=”ControlVendorAssembly”/>
</controls>
</pages>

</system.web>

</configuration>

Aug 12
  1. Add Debug=”true” to your @Page directive.

  2. Place <%= GetType().Assembly.Location %>somewhere on your page

This will print the location of the assembly generated for your page. If you go to that directory, you will also see source code files (*.cs or *.vb) that contain the class definitions

This article has been posted at miami dating site architect providing free online dating service. Surprises never cease so as the growth of our online dating site, which has been on ramapage.

Aug 12
  1. Create a web application in VS.NET
  2. Add a button control on the Page
  3. Import namespace System.Mail
  4. Write down following code in the click event of the button
protected void Button1_Click(object sender, EventArgs e)

{

//Create Mail Message Object with content that you want to send with mail.

MailMessage MyMailMessage = new MailMessage
                  ("test@gmail.com","myfriend@domain.com",
                  "This is the mail subject", "Just wanted to say Hello");
MyMailMessage.IsBodyHtml = false;
//Proper Authentication Details need to be passed when sending email from gmail
NetworkCredential mailAuthentication = new NetworkCredential("test@gmail.com", "myPassword");
//Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
//For different server this details changes and you can

//get it from respective server.

SmtpClient mailClient = new SmtpClient("smtp.gmail.com",587);
//Enable SSL
mailClient.EnableSsl = true;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = mailAuthentication;
mailClient.Send(MyMailMessage);

}

This article has been posted by the online dating site architect hosting monthly contest
and providing the finest quality free online dating service. Our website is also powered by
Google App. But beware, Google is notorious of blocking lot of Outgoing emails and
lot of webserver block emails coming from google server.
Aug 12
  1. Create a new Web Application in VS.NET
  2. Add a button control to the page .
  3. write down following code in the click event of the button
    protected void Button1_Click(object sender, EventArgs e)
    {

        string strConn = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();

        SqlConnection conn = new SqlConnection(strConn);

        SqlDataAdapter da = new SqlDataAdapter("select * from tablename ", conn);

        DataSet ds = new DataSet();

        da.Fill(ds, "tbl");

        GridView1.DataSource = ds.Tables["tbl"].DefaultView;

        GridView1.DataBind();

        DataTable dt = ds.Tables["Emp"];

        CreateCSVFile(dt, "c:\\csvData.csv");

    }

 public void CreateCSVFile(DataTable dt, string strFilePath)
    {
        // Create the CSV file to which grid data will be exported.
        StreamWriter sw = new StreamWriter(strFilePath, false);
        // First we will write the headers.

        int iColCount = dt.Columns.Count;
        for (int i = 0; i < iColCount; i++)
        {
            sw.Write(dt.Columns[i]);
            if (i < iColCount - 1)
            {
                sw.Write(",");
            }
        }
        sw.Write(sw.NewLine);
        // Now write all the rows.
        foreach (DataRow dr in dt.Rows)
        {
            for (int i = 0; i < iColCount; i++)
            {
                if (!Convert.IsDBNull(dr[i]))
                {
                    sw.Write(dr[i].ToString());
                }
                if (i < iColCount - 1)
                {
                    sw.Write(",");
                }
            }
            sw.Write(sw.NewLine);
        }
        sw.Close();
    }

This article has been posted by the online dating site architect hosting monthly contest and providing the finest quality free online dating service.
Aug 12

Here is an example of how you can add a map to any contact us page or blog quickly
and easily.
•First you need a google api key ,which is free. You can find it,along with other
documentation at
http://www.google.com/apis
Follow the instructions to “Sign up for a google API key”. You’ll need a gmail
account, and to enter your domain name. This key can then only be used on pages
served from that domain name. Along with your key, Google will give you a bit of
starter code.
Now create a new web application in vs.net and copy the highlited code in head
section of your .aspx page.(replace [YOURKEY] with actual key)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GoogleMap.aspx.cs"
    Inherits="GoogleMap" %>

<!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>
    <title></title>
    <script src="http://maps.google.com/maps?file=api&v=2&key=
[YOURKEY]" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
        function showMap()
         {
                if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GSmallMapControl());
                map.setCenter(new GLatLng(31.95216223802497, -7.71875), 1);
            }
        }
    //]]>
    </script>

</head>
<body onload="showMap();" onunload="GUnload()">
    <form id="form1" runat="server">
        <div id="map" style="width: 500px; height: 300px">
        </div>
    </form>
</body>
</html>

This article has been posted by online dating site architect providing free online dating service.
Aug 12

Here’s the scenario - let’s say you have an Insert subroutine, called ‘doInsert’. You want to immediately disable the Submit button, so that the end-user won’t click it multiple times, therefore, submitting the same data multiple times.

For this, use a regular HTML button, including a Runat=”server” and an ‘OnServerClick’ event designation - like this:

< id=”Button1″ onclick=”">=true;” type=”button” value=”Submit - Insert Data” name=”Button1″ runat=”server” onserverclick=”doInsert”>

Then, in the very last line of the ‘doInsert’ subroutine, add this line:

Button1.enabled=”True”

This article has been posted at miami dating site architect providing free online dating service.