Scriptmanager..RegisterStartup ... [英] Scriptmanager..RegisterStartup...

查看:64
本文介绍了Scriptmanager..RegisterStartup ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络表单中有4个字段并且在成功插入后尝试插入数据库我想使用ScriptManager.RegisterStartupScript显示警报消息(this,this.GetType(),ShowSuccess,javascript:Display('+ txtname.Text +'),true);





功能





功能显示(姓名){

提醒(姓名; :::已成功插入;);



}



但是当我编译它时显示错误为类型或命名空间RegisterStartUpScript在命名空间Scriptmanager中不存在(你是否缺少程序集引用) )

i已添加所有推荐



i have 4 field in web form and trying to insert in database after successfull insertion i want to show alert message using ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('" + txtname.Text + "')", true);


function


function Display(name) {
alert(name;:::Inserted successfully;);

}

but when i compile it is showing error as "The type or namespace RegisterStartUpScript does not exist in the namespace Scriptmanager(are you missing an assembly reference")
i have added all refernce

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

推荐答案

< b>在ASPX页面上



On ASPX PAGE

<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>]]>



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript" type="text/javascript">
    function Display(name) {
        alert(name + ':-  Insert Successfully');
    }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    
    
    
    </form>
</body>
</html>









在ASPX.CS页面上









On ASPX.CS PAGE


using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "javascript:Display('"+txtbox.Text+"')", true);
    }
}









请尝试它它正在工作..





Please Try It it is working ..


hi sachin mca2012,



我检查了arif ansari的代码正在运行f9你可以去还有以下内容,



hi sachin mca2012,

I checked that arif ansari's code is working f9 you can go with following as well,

protected void Button1_Click(object sender, EventArgs e)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowSuccess", "callit()", true);
        
     }





并将代码放在head标签的脚本标签中代码





and put below code in script tag in head tag

<script  type="text/javascript">
       function callit()
       {
           alert("call successfull");
       }

   </script>




按钮点击事件中的
如果您将所有数据保存代码放在此注册脚本之前数据插入不会成功,此代码执行不会转到此行..



in button click event put your all data saving code before this register script if you data insertion will not be success this code execution will not go to this line..


这篇关于Scriptmanager..RegisterStartup ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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