ASP.NET2.0中创建模态对话框提交按钮不起作用,什么原因?

本文探讨了ASP.NET2.0环境下创建模态对话框时遇到的问题,即点击提交按钮后对话框未关闭且未能将信息保存到数据库的情况。作者详细展示了页面的代码实现,并请求帮助解决按钮点击事件不起作用的问题。

 

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

public partial class Admin_Links_AddEditLinks : System.Web.UI.Page
{
    DBUtility.TSqlDB Db 
= new DBUtility.TSqlDB();
    JSModel.TJavaScript JS 
= new JSModel.TJavaScript();
    FileModel.UpLoadFile upFile 
= new FileModel.UpLoadFile();

    
protected void Page_Load(object sender, EventArgs e)
    
{
        Response.Expires 
= 0;
        Response.Cache.SetNoStore();
        Response.AppendHeader(
"Pragma""no-cache");

        
new CheckUser();
        
if (Request["LId"!= null)
        
{
            SqlDataReader Dr 
= Db.ExecuteReader(Db.myCon, CommandType.Text, "select * from tb_HyperLink where dc_Id="+Request["LId"], null);
            
if (Dr.Read())
            
{
                txtLinkName.Text 
= Dr["vc_LinkName"].ToString();
                txtLinkUrl.Text 
= Dr["vc_LinkUrl"].ToString();
                HWhere.Value 
= Dr["vc_LogoUrl"].ToString();
            }

            Dr.Close();
        }

    }


    
protected void btnAdd_Click(object sender, EventArgs e)
    
{
        
if (FileUpload1.HasFile && FileUpload1.PostedFile.ContentLength > 2)
        
{
            
string[] arr =".jpg"".gif" };
            HWhere.Value 
= upFile.UploadFile(FileUpload1, "/Uploads/Link/"1024, arr, HWhere.Value == "", HWhere.Value);
            
if (HWhere.Value == "")
            
{
                
return;
            }

        }


        SqlParameter[] prams 
= new SqlParameter[]{
            
new SqlParameter("@dc_Id",SqlDbType.Decimal),
            
new SqlParameter("@vc_LinkName",SqlDbType.VarChar,50),
            
new SqlParameter("@vc_LinkUrl",SqlDbType.VarChar,200),
            
new SqlParameter("@vc_LogoUrl",SqlDbType.VarChar,200),
            
new SqlParameter("@i_Mid",SqlDbType.Int),
            
new SqlParameter("@AdminId",SqlDbType.VarChar,200),
            
new SqlParameter("@i_Ret",SqlDbType.Int)
        }
;

        prams[
0].Value = Request["LId"== null ? "0" : Request["LId"];
        prams[
1].Value = txtLinkName.Text;
        prams[
2].Value = txtLinkUrl.Text;
        prams[
3].Value = HWhere.Value;
        prams[
4].Value = Request["Mid"];
        prams[
5].Value = Request.Cookies["AdminId"].Value;
        prams[
6].Direction = ParameterDirection.Output;

        Db.ExecuteNonQuery(Db.myCon, CommandType.StoredProcedure, 
"Pap_HyperLink", prams);
        
if (prams[6].Value.ToString() == "1")
        
{
            
if (Request["LId"== null)
            
{
                JS.MsgBox(
"提示:链接信息添加成功!");
            }

            
else
            
{
                JS.MsgBox(
"提示:链接信息编辑成功!");
            }

            JS.ReloadWindow();
        }

        JS.Redirect(Request.RawUrl);
    }

}

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddEditLinks.aspx.cs" Theme="StyleThemes"
    Inherits
="Admin_Links_AddEditLinks" 
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
<title>编辑友情链接信息</title>
    
<meta http-equiv="Expires" content="0" />
    
    
<link href="../Style/Style.css" rel="stylesheet" type="text/css" />

    
<script language="javascript" src="../../JSBlock/UseCheck.js" type="text/javascript"></script>

    
<script language="javascript" type="text/javascript">
        
function Check()
        
{
            
if(document.form1.txtLinkName.value=="")
            
{
                alert(
"提示:请输入网站名称!");
                document.form1.txtLinkName.focus();
                
return false;
            }

            
if(document.form1.txtLinkUrl.value=="")
            
{
                alert(
"提示:请输入网站链接地址!");
                document.form1.txtLinkUrl.focus();
                
return false;
            }

            
if(TestReg(document.form1.txtLinkUrl.value)==false)
            
{
                alert(
"提示:请输入合法的链接地址!");
                document.form1.txtLinkUrl.select();
                
return false;
            }

        }

    
</script>

</head>
<body>
    
<form id="form1" method="post" runat="server">
        
<div class="divA">
            
<table border="0" cellpadding="0" cellspacing="8" width="100%">
                
<tr>
                    
<td>
                        网站名称:
<asp:TextBox ID="txtLinkName" runat="server" Width="173px"></asp:TextBox>
                    
</td>
                
</tr>
                
<tr>
                    
<td>
                        链接地址:
<asp:TextBox ID="txtLinkUrl" runat="server" Width="237px"></asp:TextBox>
                    
</td>
                
</tr>
                
<tr>
                    
<td>
                        图片地址:
<asp:FileUpload ID="FileUpload1" CssClass="btnA" runat="server" />
                    
</td>
                
</tr>
                
<tr>
                    
<td align="center" style="height: 50px;">
                        
<asp:Button ID="btnAdd" OnClientClick="return Check();" runat="server" Text="确定"
                            OnClick
="btnAdd_Click" />
                        
&nbsp; &nbsp; &nbsp; &nbsp;
                        
<input id="Reset1" class="btnA" type="reset" value="重置" />
                        
&nbsp; &nbsp; &nbsp; &nbsp;
                        
<input type="button" class="btnA" value="关闭" onclick="javascript:window.close();" />
                    
</td>
                
</tr>
            
</table>
            
<input type="hidden" id="HWhere" name="HWhere" runat="server" />
        
</div>
    
</form>
</body>
</html>

ASP.NET2.0中创建模态对话框(showModalDialog)用来向数据库中添加信息,点击提交按钮怎么不起作用?反而把这个网页在浏览器中显示出来添加信息即可成功!请高手指点我该怎么设计? 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值