错误: 无法跳转,原因:
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit(); //////对象不支持此属性或方法。
}
}
前台部分:
跳转到:<asp:DropDownList ID="change" AutoPostBack="true" OnSelectedIndexChanged="ChangeLink" runat="server" Height="18" style="font-size: 12px; color: gray">
</asp:DropDownList>
后台部分:
public partial class New_Show : System.Web.UI.Page
{
public string connection = System.Configuration.ConfigurationSettings.AppSettings["DZW2008ConnectionString2"];
public string menu,id;
PagedDataSource MyPaged = new PagedDataSource();
DataSet News = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request["Class_Id"].Trim().Length > 0)
{
id = Request["Class_Id"].Trim();
}
if (Request["Class_Name"].Trim().Length > 0)
{
id = GetNewClass(Request["Class_Name"].Trim());
}
string sql = "select Dz_News.*,Dz_Menu.Menu_Name from Dz_News,Dz_Menu where Dz_Menu.Menu_Id = Dz_News.New_Type and Dz_Menu.Menu_Id ='" + id + "' and Dz_News.IsDel ='0' order by Dz_news.add_time Desc"; SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
// Adapter.Fill(News); ////////////////////////////////////
try
{
//填充数据集\
adapter.Fill(News);
// MyAdapter.Fill(MySet);
//创建分页类 //设置数据源
MyPaged.DataSource = News.Tables[0].DefaultView; //允许分页
MyPaged.AllowPaging = true;
//设置每页显示的项数
MyPaged.PageSize = 5;
//定义变量用来保存当前页索引
int MyCurrentPage;
//判断是否具有页面跳转的请求
if (Request.QueryString["Page"] != null)
MyCurrentPage = Convert.ToInt32(Request.QueryString["Page"]);
else
MyCurrentPage = 1;
//设置当前页的索引
MyPaged.CurrentPageIndex = MyCurrentPage - 1;
//显示状态信息
this.Label1.Text = "共有新闻<font color='red'>" + News.Tables[0].Rows.Count.ToString() + "</font>条 当前页:<font color='red'>" + MyCurrentPage.ToString() + "/</font>" + MyPaged.PageCount;
// this.Label3.Text = "共有各类信息<font color='red'>" + MySet.Tables[0].Rows.Count.ToString() + "</font>条 当前页:<font color='red'>" + MyCurrentPage.ToString() + "/</font>" + MyPaged.PageCount;
//如果当前页面不是首页
if (MyPaged.IsFirstPage)
{
this.HperLink3.Visible = false;
}
if (!MyPaged.IsFirstPage)
{
this.HperLink3.Visible = true;
this.HperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1"+"&Class_Id=" + id+"&Class_Name=";
//设置"上一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage - 1 + "&Class_Id=" + id+"&Class_Name=");
// this.HyperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage - 1);
}
//如果当前页面不是最后一页
if (!MyPaged.IsLastPage)
{
//设置"下一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.HyperLink4.Visible = true;
this.HyperLink4.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + MyPaged.PageCount + "&Class_Id=" + id + "&Class_Name=";
this.HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage + 1 + "&Class_Id=" +id +"&Class_Name="); // this.HyperLink4.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage + 1);
}
//进行数据绑定
this.new_list.DataSource = MyPaged;
this.new_list.DataBind();
this.change.Items.Clear();
for (int i = 1; i <= MyPaged.PageCount; i++)
{
//this.change.Items.Clear();
ListItem list = new ListItem();
list.Value = i.ToString();
list.Text = "第" + i + "页";
this.change.Items.Add(list);
// this.change.DataValueField = i.ToString(); }
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
News.Dispose();
}
menu = News.Tables[0].Rows[0]["Menu_Name"].ToString();
}
}
public string GetNewClass(string id)
{
////未写出。
} protected void ChangeLink(object sender, EventArgs e)
{
this.change.AutoPostBack = true;
Response.Write(Request.CurrentExecutionFilePath + "?Page=" + change.SelectedItem.Value.ToString() + "&Class_Id=" + id + "&Class_Name=");
}
}高手看看。小弟感谢。
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit(); //////对象不支持此属性或方法。
}
}
前台部分:
跳转到:<asp:DropDownList ID="change" AutoPostBack="true" OnSelectedIndexChanged="ChangeLink" runat="server" Height="18" style="font-size: 12px; color: gray">
</asp:DropDownList>
后台部分:
public partial class New_Show : System.Web.UI.Page
{
public string connection = System.Configuration.ConfigurationSettings.AppSettings["DZW2008ConnectionString2"];
public string menu,id;
PagedDataSource MyPaged = new PagedDataSource();
DataSet News = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request["Class_Id"].Trim().Length > 0)
{
id = Request["Class_Id"].Trim();
}
if (Request["Class_Name"].Trim().Length > 0)
{
id = GetNewClass(Request["Class_Name"].Trim());
}
string sql = "select Dz_News.*,Dz_Menu.Menu_Name from Dz_News,Dz_Menu where Dz_Menu.Menu_Id = Dz_News.New_Type and Dz_Menu.Menu_Id ='" + id + "' and Dz_News.IsDel ='0' order by Dz_news.add_time Desc"; SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
// Adapter.Fill(News); ////////////////////////////////////
try
{
//填充数据集\
adapter.Fill(News);
// MyAdapter.Fill(MySet);
//创建分页类 //设置数据源
MyPaged.DataSource = News.Tables[0].DefaultView; //允许分页
MyPaged.AllowPaging = true;
//设置每页显示的项数
MyPaged.PageSize = 5;
//定义变量用来保存当前页索引
int MyCurrentPage;
//判断是否具有页面跳转的请求
if (Request.QueryString["Page"] != null)
MyCurrentPage = Convert.ToInt32(Request.QueryString["Page"]);
else
MyCurrentPage = 1;
//设置当前页的索引
MyPaged.CurrentPageIndex = MyCurrentPage - 1;
//显示状态信息
this.Label1.Text = "共有新闻<font color='red'>" + News.Tables[0].Rows.Count.ToString() + "</font>条 当前页:<font color='red'>" + MyCurrentPage.ToString() + "/</font>" + MyPaged.PageCount;
// this.Label3.Text = "共有各类信息<font color='red'>" + MySet.Tables[0].Rows.Count.ToString() + "</font>条 当前页:<font color='red'>" + MyCurrentPage.ToString() + "/</font>" + MyPaged.PageCount;
//如果当前页面不是首页
if (MyPaged.IsFirstPage)
{
this.HperLink3.Visible = false;
}
if (!MyPaged.IsFirstPage)
{
this.HperLink3.Visible = true;
this.HperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=1"+"&Class_Id=" + id+"&Class_Name=";
//设置"上一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.HyperLink1.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage - 1 + "&Class_Id=" + id+"&Class_Name=");
// this.HyperLink3.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage - 1);
}
//如果当前页面不是最后一页
if (!MyPaged.IsLastPage)
{
//设置"下一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.HyperLink4.Visible = true;
this.HyperLink4.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + MyPaged.PageCount + "&Class_Id=" + id + "&Class_Name=";
this.HyperLink2.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage + 1 + "&Class_Id=" +id +"&Class_Name="); // this.HyperLink4.NavigateUrl = Request.CurrentExecutionFilePath + "?Page=" + Convert.ToString(MyCurrentPage + 1);
}
//进行数据绑定
this.new_list.DataSource = MyPaged;
this.new_list.DataBind();
this.change.Items.Clear();
for (int i = 1; i <= MyPaged.PageCount; i++)
{
//this.change.Items.Clear();
ListItem list = new ListItem();
list.Value = i.ToString();
list.Text = "第" + i + "页";
this.change.Items.Add(list);
// this.change.DataValueField = i.ToString(); }
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
News.Dispose();
}
menu = News.Tables[0].Rows[0]["Menu_Name"].ToString();
}
}
public string GetNewClass(string id)
{
////未写出。
} protected void ChangeLink(object sender, EventArgs e)
{
this.change.AutoPostBack = true;
Response.Write(Request.CurrentExecutionFilePath + "?Page=" + change.SelectedItem.Value.ToString() + "&Class_Id=" + id + "&Class_Name=");
}
}高手看看。小弟感谢。
解决方案 »
- 2003系统 iis6.0 没遇到过的问题
- gridview实现下载?
- 活动目录中怎样根据LDAP获取域名
- 小问题,在显示数值时如何用逗号分开?
- 找.net高手!
- 如何在代码中设置textbox.onTextChanged属性
- URL中的#字符如何转义,http://localhost/c#文章.txt如何访问?
- 先在IIS中新建一个虚拟目录myweb,物理目录是d:\myweb。然后再在VS.Net中新建一个ASP.NET应用程序,在位置一栏写:http://localhost/mywe
- 用什么办法关闭窗口比较好?
- 用C#创建DataSet时,无法添加DataTable的column
- sql语句的问题!问题解决九给分
- 隐藏容器内事件失效问题
在aspx文件里的所有标签的ID命名是有限制的,简单例子:像submit,function之类的javascript的关键词是不能用的。同样DOM里的关键词也是不能用的。我之前就是因为用了submit做ID而出现了和你现在一样的错误提示。
你可以用html注释把你页面上的标签一个个注释掉,每注释一个就测一下,这样就知道是哪个标签的ID有问题了。
如果页面上的标签太多,无法这样测,那就把所有的ID名字改成xx_xx这样有前缀加下划线的,就不会有问题了。
希望对你有帮助。