当前位置: 代码迷 >> ASP.NET >> ClientScript.RegisterStartupScript()的用法?该如何处理
  详细解决方案

ClientScript.RegisterStartupScript()的用法?该如何处理

热度:9094   发布时间:2013-02-25 00:00:00.0
ClientScript.RegisterStartupScript()的用法?
前台javascript函数为:
<script language="javascript">
function showdialog()
{
  var md=window.showModalDialog("HaveView.aspx","","dialogHeight:300px;dialogLeft:200px;dialogTop:200px;dialogWidth:500px;center:no;dialogHide:no;edge:sunken;help:yes;resizable:no;scroll:no;status:no;unadorned:no;")
}
</script>

后台调用:
  protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
  if (e.CommandName == "edit")
  {
  int index = Convert.ToInt32(e.CommandArgument);
  string s = GridView1.DataKeys[index].Value.ToString();
  string comm = "select * from Customers where CustomerID='s'";
  SqlDataAdapter da = new SqlDataAdapter();
  da = sqlconnection(comm);
  DataTable mytable = new DataTable("customer");
  mytable = ds.Tables["customer"];\\ds是全局dataset
  int count = mytable.Columns.Count;
  string[] ziduan=new string[count];
  for (int i = 0; i < count; i++)
  {
  ziduan[i] = mytable.Columns[i].ColumnName.ToString();
  Application.Add("string" + i, ziduan[i]);
  }

  Page.ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "showdialog()");
  }

  }
为什么点"编辑"按钮后,没反应呢?请高手指教。

------解决方案--------------------------------------------------------
你是要后台调用JS吧
、?

JScript code
ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "<script>showdialog()</script>");
------解决方案--------------------------------------------------------
C# code
Page.ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "showdialog()", true);
------解决方案--------------------------------------------------------
Page.ClientScript.RegisterStartupScript(ClientScript.GetType(), "showwindow", "<script>showdialog()</script>");


ScriptManager.RegisterStartupScript(this, this.GetType(), "showwindow", "showdialog()", true);
------解决方案--------------------------------------------------------
ClientScript.RegisterStartupScript(this.GetType(), "showwindow", "showdialog()", true);


  相关解决方案