Imports System Imports System.Drawing Imports System.Collections Imports System.Collections.Specialized Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports AspNetForums Imports AspNetForums.Components Imports System.ComponentModel Imports System.Web.Security Namespace AspNetForums.Controls ' 'ToDo: Error processing original source shown below 'System.Char[] '^--- Syntax error: '}' expected ' ********************************************************************* // Login // /// /// This server control renders and handles the login UI for the user. /// // ***********************************************************************/ [ ParseChildren(true) ] public class Login : SkinnedForumWebControl { string skinFilename = "Skin-Login.ascx"; TextBox username; TextBox password; Button loginButton; CheckBox autoLogin; // ********************************************************************* // Login // /// /// Constructor /// // ***********************************************************************/ public Login() : base() { // Assign a default template name if (SkinFilename == null) SkinFilename = skinFilename; } // ********************************************************************* // CreateChildControls // /// /// This event handler adds the children controls. /// // ***********************************************************************/ protected override void CreateChildControls() { // If the user is already authenticated we have no work to do if (Page.Request.IsAuthenticated) return; base.CreateChildControls(); } // ********************************************************************* // Initializeskin // /// /// Initialize the control template and populate the control with values /// // ***********************************************************************/ override protected void InitializeSkin(Control skin) { // Find the username control username = (TextBox) skin.FindControl("username"); // Find the password control password = (TextBox) skin.FindControl("password"); // Find the login button loginButton = (Button) skin.FindControl("loginButton"); loginButton.Click += new System.EventHandler(LoginButton_Click); // Find the autologin checkbox autoLogin = (CheckBox) skin.FindControl("autoLogin"); } // ********************************************************************* // LoginButton_Click // /// /// Event handler to handle the login button click event /// // ***********************************************************************/ public void LoginButton_Click(Object sender, EventArgs e) { User userToLogin = new User(); string redirectUrl = null; userToLogin.Username = username.Text; userToLogin.Password = password.Text; if (Users.ValidUser(userToLogin)) { FormsAuthentication.SetAuthCookie(userToLogin.Username, autoLogin.Checked); redirectUrl = Page.Request.QueryString["ReturnUrl"]; if (redirectUrl != null) { Page.Response.Redirect(redirectUrl); Page.Response.End(); } else { Page.Response.Redirect(Globals.UrlHome); Page.Response.End(); } } } } } End Namespace 'AspNetForums.Controls
Imports System Imports System.Xml Imports System.Xml.XPath Imports System.Web Imports System.Net Imports System.Configuration Namespace GolfClubShack _ Public Class NewsFunctions Public Sub New() End Sub 'New Private Shared Function GetRemoteXML(url As String, filter As String) As String Dim req As WebRequest = Nothing Dim resp As WebResponse = Nothing Dim reader As XmlTextReader = Nothing Dim newsHTML As String = [String].Empty Dim xpath As String = "//article[contains(translate(headline_text,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'),'" + filter + "')]" Try req = WebRequest.Create(url) resp = req.GetResponse() reader = New XmlTextReader(resp.GetResponseStream()) Dim doc As New XmlDocument() doc.Load(reader) Dim nodeList As XmlNodeList = doc.SelectNodes(xpath) Dim count As Integer = nodeList.Count Dim i As Integer For i = 0 To count - 1 newsHTML += """" + nodeList(i).SelectSingleNode("url").InnerText + """,""" + nodeList(i).SelectSingleNode("headline_text").InnerText + """" If i <> count - 1 Then newsHTML += "," End If Next i Catch End Try Return newsHTML End Function 'GetRemoteXML Public Shared Sub UpdateCache(cacheName As String, url As String, filter As String, duration As Integer) Dim context As HttpContext = HttpContext.Current context.Cache.Insert(cacheName, GetRemoteXML(url, filter), Nothing, DateTime.Now.AddMinutes(duration), TimeSpan.Zero) End Sub 'UpdateCache End Class 'NewsFunctions End Namespace 'GolfClubShack