Click here to Skip to main content
15,916,189 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionName 'lstSubscriptions_SelectedIndexChanged' is not declared. [modified] Pin
Rob Howard23-Jul-06 20:27
Rob Howard23-Jul-06 20:27 
Hey folks, any help on this would be great. I'm trying to create an online RSS Reader and I've run into a snag. Following is the code that I've got that's erroring out. The line that is erroring out is " lstSubscriptions_SelectedIndexChanged(Nothing, Nothing)"

And thanks again in advance for any help.


Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
btnSubscribe.Enabled = False
'---When the form loads for the first time ---'
Dim FeedNames() As String = Profile.FeedNames.Split(";")
Dim FeedURLs() As String = Profile.FeedURLs.Split(";")
'---Populate the ListBox control---'
For i As Integer = 0 To FeedNames.Length - 2
Dim listItem As New ListItem(FeedNames(i), FeedURLs(i))
lstSubscriptions.Items.Add(listItem)
Next
'---Select the first item in the List Box ---'
If lstSubscriptions.Items.Count > 0 Then
lstSubscriptions.SelectedIndex = 0
lstSubscriptions_SelectedIndexChanged(Nothing, Nothing)
End If
End If
End Sub

Protected Sub btnVerifyFeed_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnVerifyFeed.Click
'---Load the RSS feed XML document and extract the title ---'
txtFeedTitle.Text = LoadFeed(txtRssURL.Text)
If txtFeedTitle.Text = String.Empty Then
DisplayError("Feed did not load correctly.")
Else
btnSubscribe.Enabled = True
End If
End Sub
End Class

Protected Sub DisplayError(ByVal msg As String)
'---Display a Window on the client side ---'
Dim script As String = "alert('" & msg & "');"
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "Key", script, True)
End Sub

Public Function LoadFeed(ByVal URI As String) As String
Dim req As HttpWebRequest
Dim xmlDoc As XmlDocument = Nothing
Try
req = SendRequest(URI, "GET")
Dim xmlData As String = GetResponse(req)
xmlDoc = New XmlDocument()
xmlDoc.LoadXml(xmlData)
'---Select the title of the document---'
Dim titleNode As XmlNode = xmlDoc.DocumentElement.SelectSingleNode("channel/title")
Return titleNode.InnerText
Catch ex As Exception
Return String.Empty
End Try
End Function

Public Function SendRequest(ByVal URI As String, ByVal requestType As String) As HttpWebRequest
Dim req As HttpWebRequest = Nothing
Try
'---Creates a HTTP request ---'
req = HttpWebRequest.create(URI)
req.Method = requestType '---Get or POST---'
Catch ex As Exception
Throw New Exception("Error")
End Try
End Function

Public Function GetResponse(ByVal req As HttpWebRequest) As String
Dim body As String = String.Empty
Try
'---Get a responce from server---'
Dim resp As HttpWebResponse = req.GetResponse()
Dim Stream As Stream = resp.GetResponseStream()
'---Use a StreamReader to read the response---'
Dim reader As StreamReader = New StreamReader(stream, Encoding, UTF8)
body = reader.ReadToEnd()
stream.Close()
Catch ex As Exception
Throw New Exception("Error")
End Try
Return body
End Function

Protected Sub lstSubscription_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstSubscriptions.SelectedIndexChanged
Try
'---Bind the XmlDataSource control to the selected item URL---'
XmlDataSource1.DataFile = lstSubscriptions.SelectedItem.Value
Catch ex As Exception
DisplayError("Error displaying the feed.")
End Try
End Sub

Protected Sub btnSubscribe_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubscribe.Click
'---If user did not enter an URL ---'
If txtRssURL.Text = String.Empty Then
DisplayError("Please enter the feed URL.")
Exit Sub
End If
'---Bind the XmlDataSource Control to the URL Specified---'
XmlDataSource1.DataFile = txtRssURL.Text
'---Add tot he ListBox Control---'
Dim listItem As New ListItem(Trim(txtFeedTitle.Text), Trim(txtRssURL.Text))
'---If no duplicate entry in the ListBox---'
If Not lstSubscriptions.Items.Contains(listItem) Then
lstSubscriptions.Items.Add(listItem)
lstSubscriptions.SelectedIndex = lstSubscriptions.Items.Count - 1
'---Add to the Profile properties---'
Profile.FeedNames += Trim(txtFeedTitle.Text) & ";"
Profile.FeedURLs += Trim(txtRssURL.Text) & ";"
Else
DisplayError("Feed is already subscribed.")
End If
btnSubscribe.Enabled = False
End Sub

Protected Sub btnUnsubscribe_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUnsubscribe.Click
Try
'---Remove the unsubsribed URL from the Profile properties---'
Profiles.FeedNames = Profile.FeedNames.Remove(Profile.FeedNames.IndexOf(lstSubscriptions.SelectedItem.Text), lstSubscriptions.SelectedItem.Text.Length + 1)
Profiles.FeedURLs = Profile.FeedURLs.Remove(Profiles.FeedURLs.IndexOf(lstSubscriptions.SelectedItem.Value), lstSubscriptions.SelectedItem.Value.Length + 1)

'---Remove the item from the ListBox Control---'
lstSubscriptions.Items.Remove(lstSubscriptions.SelectedItem)

'---Select the first item in the ListBox---'
If lstSubscriptions.Items.Count > 0 Then
lstSubscriptions.SelectedIndex = 0
lstSubscriptionis_SelectedIndexChanged(Nothing, Nothing)
Else
'---ListBox is Empty; bind to the Defualt RSS---'
XmlDataSource1.DataFile = "-/RSS.xml"
DataList1.DataBind()
End If
Catch ex As Exception

End Try
End Sub



-- modified at 2:28 Monday 24th July, 2006
AnswerRe: Name 'lstSubscriptions_SelectedIndexChanged' is not declared. Pin
minhpc_bk23-Jul-06 23:35
minhpc_bk23-Jul-06 23:35 
QuestionHow can Change Formviews Default Mode? Pin
Haridas.R23-Jul-06 20:02
Haridas.R23-Jul-06 20:02 
AnswerRe: How can Change Formviews Default Mode? Pin
minhpc_bk23-Jul-06 20:15
minhpc_bk23-Jul-06 20:15 
GeneralRe: How can Change Formviews Default Mode? Pin
Haridas.R23-Jul-06 21:56
Haridas.R23-Jul-06 21:56 
QuestionCompare StartDate and EndDate Pin
Rajesh_K_Sharma23-Jul-06 18:33
Rajesh_K_Sharma23-Jul-06 18:33 
AnswerRe: Compare StartDate and EndDate Pin
sudharsong23-Jul-06 19:33
sudharsong23-Jul-06 19:33 
GeneralRe: Compare StartDate and EndDate Pin
Rajesh_K_Sharma26-Jul-06 19:40
Rajesh_K_Sharma26-Jul-06 19:40 
AnswerRe: Compare StartDate and EndDate Pin
Tirthadip23-Jul-06 19:34
Tirthadip23-Jul-06 19:34 
Questionrequest ASP.net learning video clip/ e-books Pin
cheeken2u23-Jul-06 18:12
cheeken2u23-Jul-06 18:12 
AnswerRe: request ASP.net learning video clip/ e-books Pin
ypsyong23-Jul-06 18:26
ypsyong23-Jul-06 18:26 
AnswerRe: request ASP.net learning video clip/ e-books Pin
blurMember23-Jul-06 19:17
blurMember23-Jul-06 19:17 
QuestionAbility to read through codes? Pin
blurMember23-Jul-06 17:46
blurMember23-Jul-06 17:46 
AnswerRe: Ability to read through codes? Pin
minhpc_bk23-Jul-06 18:51
minhpc_bk23-Jul-06 18:51 
GeneralRe: Ability to read through codes? Pin
blurMember23-Jul-06 19:18
blurMember23-Jul-06 19:18 
QuestionSome body help Pin
AnhTin23-Jul-06 17:42
AnhTin23-Jul-06 17:42 
AnswerRe: Some body help [modified] Pin
minhpc_bk23-Jul-06 18:27
minhpc_bk23-Jul-06 18:27 
GeneralRe: Some body help Pin
AnhTin23-Jul-06 22:16
AnhTin23-Jul-06 22:16 
GeneralRe: Some body help Pin
minhpc_bk23-Jul-06 22:28
minhpc_bk23-Jul-06 22:28 
GeneralRe: Some body help Pin
J4amieC23-Jul-06 23:05
J4amieC23-Jul-06 23:05 
GeneralRe: Some body help Pin
AnhTin23-Jul-06 23:22
AnhTin23-Jul-06 23:22 
QuestionResizing of datagrid in web application [modified] Pin
micydon23-Jul-06 17:41
micydon23-Jul-06 17:41 
AnswerRe: Resizing of datagrid in web application Pin
enjoycrack29-Jul-06 6:39
enjoycrack29-Jul-06 6:39 
Questionkeypress Pin
aqui_i23-Jul-06 17:02
aqui_i23-Jul-06 17:02 
AnswerRe: keypress Pin
YapEro23-Jul-06 17:38
YapEro23-Jul-06 17:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.