473,468 Members | 1,334 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

string.IndexOf - does not work

Hi,

code from .aspx page...

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

private void Page_Load(object sender, System.EventArgs e)
{
string strServerName =
Request.ServerVariables["SERVER_NAME"].ToUpper();

if (strServerName.IndexOf("LANT") <= 0) //Not Lant
//GETTING ERROR
{
if (strServerName.IndexOf("PAC") <= 0) //Not Pac
{
Response.Write ("<font size=2 face=Arial color=Red>To
access RADWeb site, please use one of the following...");
Response.Write ("<br><br>");
Response.Write ("<A
href='http://pac.com'>https://pac.com</a>");
Response.Write ("<br><br> OR <br><br>");
Response.Write ("<A
href='http://lant.com'>https://lant.com</a>");
Response.Write ("</font>");
Response.End();
}
}
}

-------------------------
Not getting any error while I am running the code. But if I step through the
code, watch window - value field displays 'strServerName.IndexOf' does not
exists.

Even if value is hardcode, strServerName = 'LANT', same error.

Help in this matter is greatly appreciated.

Thanks,

- Reena


Nov 15 '05 #1
4 7275
Hi Reena,

It runs fine onmy computer, what error does it give you?

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 15 '05 #2
Reena:

I'm not sure I understand, but I'll give it a crack....Mainly--- you aren't
getting an exception but it just isn't working? What is the value of
strServerName before you test for indexof?
"Reena" <pa*****@navsea.navy.mil> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
Hi,

code from .aspx page...

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

private void Page_Load(object sender, System.EventArgs e)
{
string strServerName =
Request.ServerVariables["SERVER_NAME"].ToUpper();

if (strServerName.IndexOf("LANT") <= 0) //Not Lant //GETTING ERROR
{
if (strServerName.IndexOf("PAC") <= 0) //Not Pac
{
Response.Write ("<font size=2 face=Arial color=Red>To
access RADWeb site, please use one of the following...");
Response.Write ("<br><br>");
Response.Write ("<A
href='http://pac.com'>https://pac.com</a>");
Response.Write ("<br><br> OR <br><br>");
Response.Write ("<A
href='http://lant.com'>https://lant.com</a>");
Response.Write ("</font>");
Response.End();
}
}
}

-------------------------
Not getting any error while I am running the code. But if I step through the code, watch window - value field displays 'strServerName.IndexOf' does not
exists.

Even if value is hardcode, strServerName = 'LANT', same error.

Help in this matter is greatly appreciated.

Thanks,

- Reena

Nov 15 '05 #3
there will be no error. the problem is this:
you are saying .indexof <= 0.

if it doesn't exist it will return a -1. if it does exist
it will return anything = to or > 0.

that is the POSITION in the "character array"

HTH.
JS

-----Original Message-----
Hi,

code from .aspx page...

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

private void Page_Load(object sender, System.EventArgs e)
{
string strServerName =
Request.ServerVariables["SERVER_NAME"].ToUpper();

if (strServerName.IndexOf("LANT") <= 0) //Not Lant//GETTING ERROR
{
if (strServerName.IndexOf("PAC") <= 0) //Not Pac {
Response.Write ("<font size=2 face=Arial color=Red>Toaccess RADWeb site, please use one of the following...");
Response.Write ("<br><br>");
Response.Write ("<A
href='http://pac.com'>https://pac.com</a>");
Response.Write ("<br><br> OR <br><br>");
Response.Write ("<A
href='http://lant.com'>https://lant.com</a>");
Response.Write ("</font>");
Response.End();
}
}
}

-------------------------
Not getting any error while I am running the code. But if I step through thecode, watch window - value field displays 'strServerName.IndexOf' does notexists.

Even if value is hardcode, strServerName = 'LANT', same error.
Help in this matter is greatly appreciated.

Thanks,

- Reena


.

Nov 15 '05 #4
Thanks Jerry. Fixed code to .indeof < 0. Works fine.

Thanks,

- Reena

"Jerry Sherman" <JS@nospam.com> wrote in message
news:3c****************************@phx.gbl...
there will be no error. the problem is this:
you are saying .indexof <= 0.

if it doesn't exist it will return a -1. if it does exist
it will return anything = to or > 0.

that is the POSITION in the "character array"

HTH.
JS

-----Original Message-----
Hi,

code from .aspx page...

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

private void Page_Load(object sender, System.EventArgs e)
{
string strServerName =
Request.ServerVariables["SERVER_NAME"].ToUpper();

if (strServerName.IndexOf("LANT") <=

0) //Not Lant
//GETTING ERROR
{
if (strServerName.IndexOf("PAC") <=

0) //Not Pac
{
Response.Write ("<font size=2 face=Arial

color=Red>To
access RADWeb site, please use one of the following...");
Response.Write ("<br><br>");
Response.Write ("<A
href='http://pac.com'>https://pac.com</a>");
Response.Write ("<br><br> OR <br><br>");
Response.Write ("<A
href='http://lant.com'>https://lant.com</a>");
Response.Write ("</font>");
Response.End();
}
}
}

-------------------------
Not getting any error while I am running the code. But if

I step through the
code, watch window - value field

displays 'strServerName.IndexOf' does not
exists.

Even if value is hardcode, strServerName = 'LANT', same

error.

Help in this matter is greatly appreciated.

Thanks,

- Reena


.

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Phil Powell | last post by:
if (document.location.href.indexOf('?') >= 0) document.location.href = document.location.href.substring(0, document.location.href.indexOf('?')); if (document.location.href.indexOf('#') >= 0) {...
4
by: Dim | last post by:
I found that C# has some buggy ways to process string across methods. I have a class with on global string var and a method where i add / remove from this string Consider it a buffer... with some...
17
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
2
by: claire | last post by:
I have a char that i convert to a string as follows m_tHeader.m_sshortname is defined as char; string result = new string(m_tHeader.m_sshortname); The problem is that any '\0' chars in the...
10
by: klineb | last post by:
Good Day, I have written and utility to convert our DOS COBOL data files to a SQL Server database. Part of the process requires parsing each line into a sql statement and validting the data to...
24
by: Derek Hart | last post by:
Is there an efficient line of code to count the number of instances of one string within another. If I have the sentence: "I want to go to the park, and then go home." It would give me a...
1
Atli
by: Atli | last post by:
The following small HowTo is a compilation of an original problem in getting some cookie-values through different methods of string-handling. The original Problem was posted as follows: As...
8
by: SMJT | last post by:
Does anyone know why the string contains function always returns true if the token is an empty string? I expected it to return false. "AnyOldText".Contains("") or...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.