我想显示插入成功的消息记录 [英] i want to show the message record insertedsuccessfully

查看:91
本文介绍了我想显示插入成功的消息记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按如下方式插入代码;



< protected  void  =   eventargs =   mode =   hold /> {
Sql = 插入BirthDayWish值(' + txt_name.Text + ',' + FromDate.SelectedDateValue.ToString()+ ',' + txt_mobile.Text + ',' + Todate.SelectedDateValue.ToString()+ ',' + txt_Email.Text + ','A');

尝试
{
SCon.Error = ;
SCon.ExecSql(Sql);
if (SCon.Error.ToString()!=
{
Label6.Text = Session [ 。错误]的ToString();

}

SCon.Con.Close();

}
catch (例外Ex1)
{
Response.Write(Ex1);

}
}





点击插入按钮后我想显示消息记录成功插入;



如何在asp.net中使用csharp。请帮帮我。

解决方案

删除所有这些代码然后重新开始。我可以使用SQL注入攻击删除整个数据库。然后我建议使用ASP.NET MVC,但无论哪种方式,我建议使用jquery和AJAX来执行插入并显示消息。如果您希望您的网站看起来像1996年,那么您可以在页面上放置一个文字控件,并用脚本填充它以在javascript中显示弹出消息。


此代码片段是适合的对于MVC 3,但很容易适应你正在做的任何事情。





// Jquery使用JSON提交给控制器及其值

// Controller操作将返回SUCCESS还是FAILED并基于此

//您可以使用隐藏的div或div显示您想要的任何消息没有文字

 


#IdOfElementOnPage)。live( click功能(){

insert code as follows;

<protected void="" eventargs="" mode="hold" />    {
Sql = "insert into BirthDayWish values('" + txt_name.Text + "','" + FromDate.SelectedDateValue.ToString() + "','" + txt_mobile.Text + "','" + Todate.SelectedDateValue.ToString() + "','" + txt_Email.Text + "','A')";
            
            try
            {
                SCon.Error = "";
                SCon.ExecSql(Sql);
                if (SCon.Error.ToString() != "")
                {
                    Label6.Text = Session["Error"].ToString();
                    
                }
                
                SCon.Con.Close();
                
      }
        catch (Exception Ex1)
        {
            Response.Write(Ex1);
            
        }
    }



after click the insert button i want to show the message "Records Inserted Successfully";

how to do in asp.net with csharp. please help me.

解决方案

Delete all this code and start again. I can delete your entire data base with a SQL injection attack. Then I recommend using ASP.NET MVC, but either way, I recommend using jquery and AJAX to do the insert and show the message. If you want your web site to look like 1996, then you can put a literal control on your page and populate it with script to show a popup message in javascript.


This code snippet is geared towards MVC 3 but is easily adaptable for whatever you are doing.


//Jquery using JSON to submit to the controller and its values
//Will Controller action will return either SUCCESS or FAILED and based on this
//you can display whatever message you''d like using a hidden div or div with no text


("#IdOfElementOnPage").live("click", function(){


这篇关于我想显示插入成功的消息记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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