JS弹出对话框返回值代码,上会图片的代码
分类:新闻中心

1.Default.aspx页面

后台:

美高梅游戏官网网站 1美高梅游戏官网网站 2代码

复制代码 代码如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YJPSDataAccess.AgentInfoManageDataAccess;
using System.Data;
using Common;
using System.Text;

namespace YJPS.YJPSPresentation.AgentInfoManagePresentation
{
    public partial class WebForm6 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DBHandler handler = new DBHandler();
                string userName = (string)Session["UserName"];
                DataTable dt = handler.Query("select * from YJPS_HBM_Operator where UserName ='" + userName + "'");
                XuHao.Text = dt.Rows[0]["OperatorID"].ToString();
                SuoShuBuMen.Text = dt.Rows[0]["DepartmentID"].ToString();
                Name.Text = dt.Rows[0]["Name"].ToString();
                Account.Text = dt.Rows[0]["UserName"].ToString();
                Password.Text = dt.Rows[0]["Password"].ToString();
                BianHao.Text = dt.Rows[0]["StaffID"].ToString();
                string str7 = Request.QueryString["DropDownList1"];
                string stra = dt.Rows[0]["Sex"].ToString();
                if (stra == "True")
                    sex.Text = "男";
                else
                    sex.Text = "女";
                RuZhiTime.Text = dt.Rows[0]["Worktime"].ToString();
                LiZhiTime.Text = dt.Rows[0]["Offtime"].ToString();
                Phone.Text = dt.Rows[0]["Phone"].ToString();
                Email.Text = dt.Rows[0]["Email"].ToString();
                QQ.Text = dt.Rows[0]["QQNumber"].ToString();
                Add.Text = dt.Rows[0]["FamilyAddress"].ToString();
                Introduce.Text = dt.Rows[0]["Introduce"].ToString();
                StringBuilder sb = new StringBuilder();
                sb.Append(@"~/Image/OperaterImage/");
                sb.Append(dt.Rows[0]["Photo"].ToString());
                I_Image.ImageUrl = sb.ToString();
            }

        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //判断用户是否选择修改了照片,不同有操作有相应的修改方式
            if (!string.IsNullOrEmpty(TB_Hide.Text))
            {
                string _delPath = L_lable1.Text;

                //删除之前照片是否成功
                if (DeletePic(_delPath))
                {
                    string _picName = I_Image.ImageUrl.Substring(12);
                    //取得临时照片的地址
                    string _sourcePath = Server.MapPath(I_Image.ImageUrl.Substring(1));

                    //设置最终保存照片的地址
                    string _destPath = Server.MapPath(@"/Image/OperaterImage/" + _picName);

                    try
                    {
                        //从临时文件夹将照片剪切到最终文件夹
                        System.IO.File.Move(_sourcePath, _delPath);
                    }
                    catch
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('修改失败!')", true);
                        return;
                    }
                    string _id = this.Account.Text;
                    AgentInfoManage _bl = new AgentInfoManage();
                    //将更改的数据提交到数据库
                    bool _b = _bl.EditAgentInfo(Password.Text.ToString(), Phone.Text.ToString(), Email.Text, int.Parse(QQ.Text), Add.Text, Introduce.Text, XuHao.Text, I_Image.ImageUrl);
                    if (_b)
                    {
                        I_Image.ImageUrl = @"/Image/OperaterImage/" + _picName;

                        TB_Path.Text = "";

                        TB_Hide.Text = "";

                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('修改成功!')", true);

                    }
                    else
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('修改失败!')", true);
                }
            }
            else
            {

                string id = this.Account.Text;
                AgentInfoManage bl = new AgentInfoManage();
                bool b = bl.EditAgentInfo(Password.Text.ToString(), Phone.Text.ToString(), Email.Text, int.Parse(QQ.Text), Add.Text, Introduce.Text, XuHao.Text,I_Image.ImageUrl);
                if (b)
                {

                    TB_Path.Text = "";

                    TB_Hide.Text = "";

                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('修改成功!')", true);

                }
                else
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('修改失败!')", true);
            }
        }

        //这是一个隐藏控件触发的事件,如果用户选择更改照片,则事件发生。
        protected void TB_Hide_Click(object sender, EventArgs e)
        {
            //用一个隐藏的Label控件保存之前照片的URL。
            L_lable1.Text = I_Image.ImageUrl.ToString();

            string picFileName = DateTime.Now.Ticks.ToString() + this.filePath.FileName;
            string path = Server.MapPath("/TempImage/");
            //将用户选择的图片保存到服务端的临时文件夹TempImage里。
            try
            {
                //对其保存的照片进行异常处理,
                filePath.PostedFile.SaveAs(path + picFileName);

            }
            catch
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "", "alert('选择照片失败!')", true);

                return;


            }
            StringBuilder sb = new StringBuilder();
            sb.Append(@"~/TempImage/");
            sb.Append(picFileName);
            //将选中的照片显示出来
            I_Image.ImageUrl = sb.ToString();

            //如果TB_Hide.Text不为空,则用户选择了更改照片
            TB_Hide.Text = sb.ToString();
        }

        //根据URL来删除本地的照片,前提是用户选择更改照片,否则不触发这个函数。
        private bool DeletePic(string _imageURL)
        {
            try
            {
                string DelServerPath = Server.MapPath(_imageURL);

                System.IO.File.Delete(DelServerPath);

                return true;
            }
            catch
            {
                return false;
            }
        }




    }
}

  1 function IsCheckBox( )
  2     {  
  3        var checkbox1 = document.getElementById("CheckBox1");
  4        var checkbox2 = document.getElementById("CheckBox2");
  5        var txtLogName = document.getElementById("txtLogName");
  6        var txtUserName = document.getElementById("txtUserName");
  7        var txtpwd = document.getElementById("txtPwd");
  8        var txtContact1 = document.getElementById("txtContact1");  
  9        var txtContact = document.getElementById("txtContact"); 
 10        var txtPos = document.getElementById("txtPos");
 11        var space = /^s*$/;
 12        //验证登陆名称
 13        if(txtLogName.value=="")
 14        {
 15             $('#lbLogName').html('*');  
 16        }
 17        else
 18        {    
 19             if(space.test(txtLogName.value))
 20             {
 21                 
 22                 $('#lbLogName').html('*'); 
 23             }
 24             else
 25             {
 26                 $('#lbLogName').html('');
 27             }
 28        }
 29        //验证用户名 
 30        if(txtUserName.value =="")
 31        {
 32            $('#lbusername').html('*');          
 33        }
 34        else
 35        {
 36             if(space.test(txtUserName.value))             
 37             { 
 38           
 39                 $('#lbusername').html('*');
 40             }
 41             else            
 42             {
 43                 $('#lbusername').html('');
 44             }
 45        }
 46        //密码
 47        if(txtpwd.value=="")
 48        {
 49           $('#lbpwd').html('*');          
 50        } 
 51        else
 52        {
 53            if(space.test(txtpwd.value))             
 54             {
 55                 $('#lbpwd').html('*');
 56             }
 57             else            
 58             {
 59                 $('#lbpwd').html('');
 60             }
 61        }   
 62        if(txtContact.value!="")
 63        {
 64          var tel =/^1[3|5|8]d{9}$/;                     
 65           if(!tel.test(txtContact.value))
 66           {             
 67               $('#lbmobel2').html('错误');                                         
 68           }
 69           else
 70           {
 71               $('#lbmobel2').html('');
 72           }
 73         }              
 74         if(txtContact1.value!="")
 75         {
 76            var tel2 = /^1[3|5|8]d{9}$/;                        
 77            if(!tel2.test(txtContact1.value))
 78            {              
 79               $('#lbmobel').html('错误');                                                    
 80            }
 81            else
 82            {
 83              $('#lbmobel').html('');
 84            }
 85        }  
 86        if(txtPos.value !="")
 87        {
 88           var pattern = /^d+$/g;        
 89           if(!pattern.test(txtPos.value))
 90           {
 91               $('#lbPos').html('*');            
 92           }          
 93        }
 94        else
 95        {
 96           $('#lbPos').html('');
 97        }
 98        //复选查询
 99      !checkbox1.checked && !checkbox2.checked? $('#Label3').html('*'):$('#Label3').html('');      
100      if(txtLogName.value==""||txtUserName.value ==""||txtpwd.value==""||(!checkbox1.checked && !checkbox2.checked))
101      {
102         return false;
103      }
104      if(txtLogName.value!="")
105      {
106         if(space.test(txtLogName.value))
107         {
108            return false;        
109         }
110      }     
111      if(txtUserName.value!="")
112      {
113         if(space.test(txtUserName.value))
114         {
115            return false;        
116         }
117      }
118      if(txtpwd.value!="")
119      {
120         if(space.test(txtpwd.value))
121         {
122            return false;        
123         }
124      } 
125      if(txtContact.value !="")
126      {
127         if(!tel.test(txtContact.value))
128         {     
129             return false;
130         }
131      }
132      if(txtcontact1.value !="")
133      {
134         if(!tel2.test(txtcontact1.value))
135         {     
136             return false;
137         }
138      }
139      if(txtPos.value !="")
140      {
141         if(!pattern.test(txtPos.value))
142         {
143             return false
144         }
145      }
146       return true;         
147     }        
148     function checkinput(value,lbmsg)
149     {
150         var space = /^s*$/;        
151         if(value!="")
152         {
153             if(space.test(value))
154             {
155                 $('#'+lbmsg).html('*'); 
156             }
157             else
158             {
159                 $('#'+lbmsg).html('');
160             }      
161         }        
162         else
163         {
164             $('#'+lbmsg).html('*'); 
165         }            
166     } 
167     function CheckModel(value,lbmsg)
168     {
169         var space = /^s*$/; //判断全空 
170         var tel = /^1[3|5|8]d{9}$/;       
171         if(value!="")
172         {   
173             if(!space.test(value)&&!tel.test(value))
174             {
175                 $('#'+lbmsg).html('错误'); 
176             }           
177             else
178             {
179                 $('#'+lbmsg).html('');
180             }  
181          } 
182         else
183         {
184             $('#'+lbmsg).html('*'); 
185         }              
186     } 
187 
188 <table cellpadding="1" cellspacing="1" style="width: 70%; font-size: 12px; text-align: center;
189                             margin-left: 200px; height: 200px;">
190                             <%--<table width="60%">--%>
191                             <tr>
192                                 <td class="tdtitle">
193                                     登录名
194                                 </td>
195                                 <td class="tdcontent">
196                                     <asp:TextBox ID="txtLogName" runat="server" MaxLength="100" onblur='checkinput(this.value,"lbLogName");'></asp:TextBox>
197                                     <asp:Label  ID="lbLogName" runat="server" ForeColor="Red"></asp:Label>                                   
198                                 </td>
199                             </tr>
200                             <tr>
201                                 <td class="tdtitle">
202                                     用户名
203                                 </td>
204                                 <td class="tdcontent">
205                                     <asp:TextBox ID="txtUserName" runat="server" MaxLength="50" onblur='checkinput(this.value,"lbusername");'></asp:TextBox>
206                                     <asp:Label  ID="lbusername" runat="server" ForeColor="Red"></asp:Label>                                  
207                                 </td>
208                             </tr>
209                             <tr>
210                                 <td class="tdtitle">
211                                     密码
212                                 </td>
213                                 <td class="tdcontent">
214                                     <asp:TextBox ID="txtPwd" runat="server" MaxLength="20" TextMode="Password" onblur='checkinput(this.value,"lbpwd");'></asp:TextBox>
215                                     <asp:Label  ID="lbpwd" runat="server" ForeColor="Red"></asp:Label>                                 
216                                 </td>
217                             </tr>
218                             <tr>
219                                 <td class="tdtitle">
220                                     上传目录
221                                 </td>
222                                 <td class="tdcontent">
223                                     <asp:TextBox ID="txtUploadDir" runat="server" MaxLength="50"></asp:TextBox>
224                                 </td>
225                             </tr>
226                             <tr>
227                                 <td class="tdtitle">
228                                     职务
229                                 </td>
230                                 <td class="tdcontent">
231                                     <asp:TextBox ID="txtPosition" runat="server" MaxLength="10"></asp:TextBox>
232                                 </td>
233                             </tr>
234                             <tr>
235                                 <td class="tdtitle">
236                                     手机
237                                 </td>
238                                 <td class="tdcontent">
239                                     <asp:TextBox ID="txtContact" runat="server" MaxLength="20" onblur='CheckModel(this.value,"lbmobel2");'></asp:TextBox>  
240                                     <asp:Label  ID="lbmobel2" runat="server" ForeColor="Red"></asp:Label>                           
241                                 </td>
242                             </tr>
243                             <tr>
244                                 <td class="tdtitle">
245                                     手机2
246                                 </td>
247                                 <td class="tdcontent">
248                                     <asp:TextBox ID="txtContact1" runat="server" MaxLength="20" onblur='CheckModel(this.value,"lbmobel");'></asp:TextBox>
249                                     <asp:Label  ID="lbmobel" runat="server" ForeColor="Red"></asp:Label>                                   
250                                 </td>
251                             </tr>
252                             <tr>
253                                 <td class="tdtitle">
254                                     项目授权
255                                 </td>
256                                 <td class="tdcontent">
257                                     <asp:DropDownList runat="server" ID="ddlProShow">
258                                         <asp:ListItem Text="请选择" Value="0"> </asp:ListItem>
259                                     </asp:DropDownList>
260                                 </td>
261                             </tr>
262                             <tr>
263                                 <td class="tdtitle">
264                                     用户设置
265                                 </td>
266                                 <td align="left">
267                                     <asp:CheckBox runat="server" Text="平台用户" ID="CheckBox1" onblur='CheckBoxonblur(this.checked,"Label3");'/>   
268                                     <asp:CheckBox runat="server" Text="客户端用户" ID="CheckBox2" onblur='CheckBoxonblur(this.checked,"Label3");'/>                       
269                                     <asp:Label ID="Label3" runat="server" ForeColor="Red"></asp:Label>
270                                 </td>
271                             </tr>
272                             <tr>
273                                 <td class="tdtitle">
274                                     排序
275                                 </td>
276                                 <td class="tdcontent">
277                                     <asp:TextBox ID="txtPos" runat="server" MaxLength="20" onblur='checkinput(this.value,"lbPos");'></asp:TextBox>
278                                     <asp:Label  ID="lbPos" runat="server" ForeColor="Red"></asp:Label>                                  
279                                 </td>
280                             </tr>
281                         </table>
282                         <div style="width: 100%; height: 30px; text-align: center; margin-top: 20px;">
283                             <asp:UpdatePanel ID="UpdatePanel1" runat="server">
284                                 <ContentTemplate>
285                                     <asp:Button ID="btnNext1" runat="server" CssClass="btn_action" Text="下一步" ValidationGroup="Validator"
286                                         OnClick="btnNext1_Click"  OnClientClick="return IsCheckBox()"/>
287                                     <asp:Button ID="btnCanle1" runat="server" CssClass="btn_action" Text="取消" OnClientClick='window.location.href="user_list.aspx";return false;' />
288                                 </ContentTemplate>
289                             </asp:UpdatePanel>
290                         </div>
291                     </div>

<script type="text/javascript">
function GetUser(TxtEmpID,TxtEmpName,url)
{
var properties = 'status:no;resizable:no;toolbar=no;menubar=no;location=no;scroll:no;dialogWidth:540px;dialogHeight:450px;'
var arg=window.showModalDialog(url,"",properties);
if(arg!=null)
{
document.getElementById(TxtEmpID).value=arg[0];
document.getElementById(TxtEmpName).value=arg[1];
}
}
</script>
<table width="240px" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 80px">
<asp:Label ID="Label1" runat="server" Text="選擇課級別一" Width="80px" class="font-w"></asp:Label></td>
<td style="width: 80px">
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="false" Width="80px" onfocus="this.blur()"></asp:TextBox>
</td>
<td style="width: 80px">
<asp:TextBox ID="TextBox2" runat="server" ReadOnly="false" Width="80px" ></asp:TextBox>
</td>
<td style="width: 80px">
<asp:Button ID="Button1" runat="server" Text="確定" OnClick="Button1_Click" CssClass="ButtonCss"/>
</td>
<td>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label></td>
<td> <asp:Label ID="Label4" runat="server" Text=""></asp:Label></td>
</tr>
</table>

  前台:

 

2.Default.aspx.cs

<%@ Page Title="" Language="C#" MasterPageFile="~/PageModel.Master" AutoEventWireup="true"
CodeBehind="AgentInfo.aspx.cs" Inherits="YJPS.YJPSPresentation.AgentInfoManagePresentation.WebForm6" %>

复制代码 代码如下:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
美高梅游戏官网网站,<style type="text/css">
.style1
{
width: 352px;
}
.style2
{
width: 127px;
}
</style>
<script type="text/javascript" language="javascript">

protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onclick", "GetUser('" + this.TextBox1.ClientID

function test(o) {
document.getElementById("<%=TB_Path.ClientID %>").value = o.value;
document.getElementById("<%=TB_Hide.ClientID %>").click();
}

  • "','" + this.TextBox2.ClientID + "','WebDialog.aspx)");
    }

</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Label runat="server" ID="L_lable1" Visible="false"></asp:Label>
<asp:Button runat="server" ID="TB_Hide" OnClick="TB_Hide_Click" />
<div>
<table border="2" style="width: 88%; height: 89px;" class="table_type">
<tr>
<td class="style2">
序号
</td>
<td class="style1">
<asp:TextBox ID="XuHao" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
所属部门
</td>
<td class="style1">
<asp:TextBox ID="SuoShuBuMen" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
姓名
</td>
<td class="style1">
<asp:TextBox runat="server" ID="Name" Enabled="false" Width="145%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
登录账号
</td>
<td class="style1">
<asp:TextBox ID="Account" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
登录密码
</td>
<td class="style1">
<asp:TextBox ID="Password" runat="server" Width="145%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
员工编号
</td>
<td class="style1">
<asp:TextBox ID="BianHao" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
性别
</td>
<td class="style1">
<asp:TextBox ID="sex" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
入职时间
</td>
<td class="style1">
<asp:TextBox ID="RuZhiTime" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
离职时间
</td>
<td class="style1">
<asp:TextBox ID="LiZhiTime" runat="server" Width="145%" Enabled="false"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
联系电话
</td>
<td class="style1">
<asp:TextBox ID="Phone" runat="server" Width="145%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
电子邮件
</td>
<td class="style1">
<asp:TextBox ID="Email" runat="server" Width="145%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
QQ号码
</td>
<td class="style1">
<asp:TextBox ID="QQ" runat="server" Width="145%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
家庭住址
</td>
<td class="style1">
<asp:TextBox ID="Add" runat="server" Width="145%"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
经纪人个人介绍
</td>
<td class="style1">
<asp:TextBox ID="Introduce" runat="server" Width="145%" Height="200px" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2">
照片
</td>
<td height="25" align="left" class="style1">
<asp:FileUpload runat="server" ID="filePath" onchange="test(this)" Style="display: none" />
<input type="button" value="选择照片" onclick="document.getElementById('<%=filePath.ClientID %>').click()" />
<asp:TextBox runat="server" ID="TB_Path" onfocus="this.blur()" />
<asp:Image ID="I_Image" runat="server" Height="150px" Width="100px" />
</td>
</tr>
</table>
</div>
<br />
<br />
                                             
<asp:Button ID="Button2" runat="server" Style="margin-left: 50px" Text="提交" Width="72px"
OnClick="Button2_Click" />
  
</asp:Content>

3.WebDialog.aspx

复制代码 代码如下:

<script language="javascript" type="text/javascript">
function Submit()
{
var arr=new Array();
arr[0]= document.getElementById('TxtEmpID').value
arr[1]= document.getElementById('TxtEmpCName').value
arr[2]= document.getElementById('TxtTitleID').value

window.returnValue=arr;
window.close();
}

</script>
<table>
<tr><td>
<asp:TextBox ID="TxtEmpID" runat="server" Width="50px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
<asp:TextBox ID="TxtEmpCName" runat="server" Width="60px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
<asp:TextBox ID="TxtTitleID" runat="server" Width="40px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
</tr></td>
<tr><td>
<input id="Button1" type="button" value="確 定" onclick="Submit()"/>
</tr></td>
</table>

您可能感兴趣的文章:

  • javascript web对话框与弹出窗口
  • javascript form 验证函数 弹出对话框形式
  • JavaScript写的一个DIV 弹出网页对话框
  • JavaScript写的一个自定义弹出式对话框代码
  • ExtJS Ext.MessageBox.alert()弹出对话框详解
  • js中常用的弹出对话框3种方式
  • js弹出模式对话框,并接收回传值的方法
  • 九种js弹出对话框的方法总结
  • html+javascript实现可拖动可提交的弹出层对话框效果
  • js showModalDialog 弹出对话框的简单实例(子窗体)
  • js弹出确认是否删除对话框
  • JavaScript弹出对话框的三种方式

本文由美高梅网址发布于新闻中心,转载请注明出处:JS弹出对话框返回值代码,上会图片的代码

上一篇:实例介绍,操作元素属性和特性 下一篇:没有了
猜你喜欢
热门排行
精彩图文