Wednesday, July 20, 2011

How to do multiple popup window using ASP.NET 3.5 and AJAX Control and Javascript?

    
There are three ways to popup a new window. The first way to do popup window,
this.lnkNewWindow.Attributes.Add("onclick", "window.open('NewWindow.aspx', 'NewWindow', 'toolbar=no, menubar=no, directories=no, resizable=yes, scrollbar=yes');return false;");
this the second way to do popup window,
<asp:LinkButton ID="lnkNewWindow" runat="server" Text="New Window" onclick="javascript:openNewWindow();” />
Put this javascript inside script tag,
  function OpenNewWindow()
  {
  window.open('NewWindow.aspx', 'NewWindow', 'toolbar=no, menubar=no, directories=no, resizable=yes, scrollbar=yes');
return false;
  }
This is the third way to do popup window,
this.lnkNewWindow.Attributes.Add("onclick", "javascript:OpenNewWindow();");
To close this window just call window.close() like this,
this.btnClose.Attributes.Add("onclick", "window.close()");
If you are doing popup window that has functionality of exporting to pdf or excel with multiview control and updatepanel. You need to put postback trigger. Here is my link.

Here are my References for popup window:

How to export to pdf or excel in ASP.NET 3.5?

Here are my references for export to pdf or excel:
Reference 1
Reference 2
Reference 3
Reference 4
Reference 5
Reference 6

Wednesday, July 6, 2011

How to extract data from site?

Web scraping (also called Web harvesting or Web data extraction) is a computer software technique of extracting information from websites.
Here is the code that extract the content of a specific site,
WebClient wc = new WebClient();
string html = string.Empty;
MatchCollection matches;
string url = string.Empty;
int id = 0;
html = wc.DownloadString(urlPath).Replace("<html>", "").Replace("</html>", "").Replace("<!DOCTYPEHTML>", "").Replace("<head>", "").Replace("</head>", "").Replace("<script>", "").Replace("</script>", "");
matches = Regex.Matches(html, "<a.*?href=\"(.*?)\".*?>(.*?)</a>", RegexOptions.IgnoreCase | RegexOptions.Singleline);
if (destinationList == null)
      destinationList = new List<clsDestinations>();
foreach (Match match in matches)
{
      string matchUrl = match.Groups[1].Value;
      //For internal links, build the url mapped to the base address
      if (match.Groups[0].Value.Contains("travel/landing_page_hotels.cfm"))
      {
            url = MapUrl(urlPath, match.Groups[1].Value);
            if (url.Length > 0)
            {
                 destination = new clsDestinations();
                 id += 1;
                 destination.ID = id;
                 destination.Url = url;
                 destination.CityName = match.Groups[2].Value;
                 if (!destinationList.Exists(d => d.CityName == destination.CityName))
                       destinationList.Add(destination);
             }
      }
}
                foreach(clsDestinations cy in destinationList)
                {
                    if (!cityBll.CheckForDuplicateCity(cy, false))
                        result += cityBll.InsertCity(cy); 
                }
Here are the references that I have used:
Once you have the data in your collection. Then you can save them one by one like this,

Sunday, July 3, 2011

How to Create a Simple Drop-Down List in MS Excel 2007?

This post is derive from this link. This post is done in microsoft excel 2007.
1.
Click on the cell in the workbook where you want your drop-down list to appear. Cell A3 is active in the image to the left (click image to enlarge it).
2.
Click the Data tab, and on the Data Tools menu, click on Data Validation. The Data Validation dialog box will appear.
3.
On the Settings tab, below Allow, click the down arrow and select List.
4.
For a simple list, type the items in the Source box in the order you want them to appear in the drop down, separating them by a comma as shown is the image. Click the OK button.
5.
Now, at the insertion point, you can click the down arrow to display the options, clicking on one to select it.


References:
http://www.ehow.com/how_4535524_simple-dropdown-list-ms-excel.html#ixzz1R7FQFMg