通过下拉列表导航到页面 [英] navigate to pages through dropdownlist

查看:103
本文介绍了通过下拉列表导航到页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string arr = new Array[] {"h.aspx","m.aspx","n.aspx","v.aspx"};
        foreach (int i in arr)
        {
            Response.Redirect[i];
        }



我不知道aray或arraylist对填充dropdownlist是否有用
而此代码有此错误


无法将类型字符串"隐式转换为"System.Array"

无法将[]的索引应用于类型为"method



i didn''t know aray or arraylist is useful to fill dropdownlist
and this code have this error


cannot implicitly convert type ''string'' to ''System.Array''

Cannot apply indexing with [] to an expression of type ''method

推荐答案

类型的表达式的问题?阅读MSDN或C#语法?还是了解Web的工作原理?

当您使用Redirect(string, bool)时,如果只能使用
What''s the problem? Reading MSDN or C# syntax? Or understanding how Web works?

As you are using Redirect(string, bool) if could be only
bool endResponse = //...
Redirect(i, endResponse); //string i is a bad variable name! name it like "index"



语法var something = Redirec[...]是用于访问读取元素的类或结构的索引属性("this")值的数组元素的语法.

请参阅 http://msdn.microsoft.com/en-us/library /a8wa7sdt%28v=vs.100%29.aspx [ ^ ].

但是如何循环执行呢?您是否要一次创建多个与数组元素一样多的网页?什么会告诉浏览器打开它们?当您的页面已经重定向到其他URL时,什么代码将重定向到其他页面?原则上不是这样.

你知道吗?您尚未准备好进行ASP.NET开发以及任何其他高级类型的应用程序.您确实非常需要从一开始就开始学习编程.毕竟,从头到尾都阅读一些语言和.NET手册,在所有章节中都进行简单的练习,最好是作为简单的控制台应用程序,以避免被您不了解的事情分散注意力.

请查看我过去的答案:框架的使用和意义 [ ^ ].

每个人都需要阅读以下内容:
Peter Norvig,十年自学编程
http://norvig.com/21-days.html [



The syntax var something = Redirec[...] is the syntax for accessing array element of reading the value of indexed property ("this") of a class or structure.

See http://msdn.microsoft.com/en-us/library/a8wa7sdt%28v=vs.100%29.aspx[^].

But how can you do it in loop? Are you trying to create several Web pages at once, as many as array elements? And what will tell the browser to open them? When your page is already redirected to some other URL, what code is going to redirect to other pages? It is not how it works in principle.

You know what? You are not ready for ASP.NET development as well as any other advanced types of applications. You really, really need to start learning programming from the very beginning. After all, read some language and .NET manual from the very beginning to the very end, do simple exercises in all chapters, preferably as simple console applications, to avoid being distracted by things you do not understand.

Please see my past answer: using and meaningful of Framework[^].

Everyone needs to read this, first of all:
Peter Norvig, Teach Yourself Programming in Ten Years,
http://norvig.com/21-days.html[^].

This is very encouraging reading.

Good luck,

—SA


这篇关于通过下拉列表导航到页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆