Input string was not in a correct format.

Member_2_5230414
Member_2_5230414 used Ask the Experts™
on
Any idea why i get Input string was not in a correct format.

for

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        forumstats.Visible = False
        Dim s As String = Request.QueryString("fn")
        If s <> "News" Or "General" Or "Training&Races" Or "Injurys&Health" Or "Other" Then

            Submit.Visible = False
        End If
    End Sub

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dirk HaestProject manager

Commented:
Probably because you want to insert the "&" in your queryString

Try to replace this

Are you looking for Server.URLEncode?
http://www.4guysfromrolla.com/webtech/042601-1.shtml

Or maybe Server.HTMLEncode and Server.HTMLDecode?
http://www.devx.com/tips/Tip/13459

Imran Javed ZiaConsultant Software Engineer - .NET Architect

Commented:
Hi,
Following is not allowed at all
        If s <> "News" Or "General" Or "Training&Races" Or "Injurys&Health" Or "Other" Then  

You may use it as

        If s <> "News" Or s <> "General" Or s <> "Training&Races" Or s <> "Injurys&Health" Or s <> "Other" Then  

Thanks

Author

Commented:
IS IT THE FACT IM USING THE OR COMMAND?
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

Author

Commented:
I tried your above suggestion IJZ but even if my link is http://localhost:2103/runningprofiles/forums/newthread.aspx?fn=News the button does not get displayed
Imran Javed ZiaConsultant Software Engineer - .NET Architect

Commented:
You are using your <> logic incorrectly
Please use it as following:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        forumstats.Visible = False
        Dim s As String = Request.QueryString("fn")
        If s = "News" Or s = "General" Or s = "Training&Races" Or s = "Injurys&Health" Or s = "Other" Then

            Submit.Visible = False
        End If
    End Sub

Author

Commented:
Just to help here is my code:

<asp:Button ID="Submit" runat="server" Text="Button"  />

and

Imports Microsoft.VisualBasic
Imports BBcode

Partial Class forums_newthread
    Inherits System.Web.UI.Page


    Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Submit.Click
        Dim s As String = Request.QueryString("fn")
   
        If s <> "News" Or s <> "General" Or s <> "Training&Races" Or s <> "Injurys&Health" Or s <> "Other" Then

            newthread.addpost(s, theTitle.Text, inputforum.Text)
        End If

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        forumstats.Visible = False
        Dim s As String = Request.QueryString("fn")
        If s <> "News" Or s <> "General" Or s <> "Training&Races" Or s <> "Injurys&Health" Or s <> "Other" Then

            Submit.Visible = False
        End If
    End Sub
End Class

Open in new window

Author

Commented:
IJZ: i want to do the code if they are not these

so if s is not the 5 names the button.visable = false
Imran Javed ZiaConsultant Software Engineer - .NET Architect

Commented:
do you want if fn=News, or General or then but should be visible or not visible
Consultant Software Engineer - .NET Architect
Commented:
Please try this


If s <> "News" And s <> "General" And s <> "Training&Races" And s <> "Injurys&Health" And s <> "Other" Then
            Submit.Visible = False
        Else
            Submit.Visible = True
        End If

Author

Commented:
Needed an else statement then :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial