如何使用JavaScript在ASP.net中使用复选框 [英] How to use checkboxes in ASP.net from javascript

查看:85
本文介绍了如何使用JavaScript在ASP.net中使用复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在ASP.net的javascript函数中访问CheckBoxes?

请帮帮我.

提前谢谢!

OP实际上意味着JavaScript,因此我正在重新编辑OP的问题[/编辑]

OP的代码:

How can I access CheckBoxes in javascript functions in ASP.net?

Please help me.

Thanks in advance!

OP did in fact mean javascript so I''m re-editing OP''s question[/Edit]

OP''s code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="tour2.aspx.cs" Inherits="tour2" %>
<!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 id="Head1"  runat="server">
    <title>www.smartwaytours.com</title>
    <script type="text/javascript">          function pageLoad() {      }
    function imageload()    {
       document.getElementById("img1").src=document.getElementById("File1").value; 
       alert(document.getElementById("img1").src);
         document.getElementById("hidHeight").value = document.getElementById("img1").height;
         document.getElementById("hidWidth").value  = document.getElementById("img1").width;
         //document.getElementById("img1").style.display="none"
         var height=document.getElementById("hidHeight").value;
         var width=document.getElementById("hidWidth").value;
         alert(height);         alert(width);                
         if((height!="61")&&(width!="64"))         { 
            alert("Hi");
            //document.getElementById("img1").style.display="";
            document.getElementById("img1").src = "images/ni(64X61).gif"
            //document.getElementById("File1").value= "fasdf";
            alert("Please upload 64 X 61 size image");            
           document.getElementById("hidHeight").value= "";
            document.getElementById("hidWidth").value= "";
            alert("ashdgjf");                        return false;           
                     }         else{         
         document.getElementById("img1").src=document.getElementById("File1").value; 
         }                    return ;     }    function imageload1()    {
        
        document.getElementById("img2").src=document.getElementById("File2").value;
        document.getElementById("HiddenField3").value = document.getElementById("img2").height;
         document.getElementById("HiddenField4").value  = document.getElementById("img2").width;
    }    function imageload2()    {        
        document.getElementById("img3").src=document.getElementById("File3").value;
        document.getElementById("HiddenField5").value = document.getElementById("img3").height;
         document.getElementById("HiddenField6").value  = document.getElementById("img3").width;
    }        function chkImg()    {       
        document.getElementById("img3").style.display = "";
        document.getElementById("File3").style.display = "";        }        
                    </script>    <style type="text/css">            
         .style3       {       	width:60%;       }         .style4        {
            text-align: right;        }     </style></head>
</head><body>    <form id="form1"  runat="server">
    <div>
    <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
                
    <table width="966" height="629" border="0" align="center" style="background-color:Aqua" cellpadding="5" cellspacing="5" id="Table_01">
      <tr>
		<td colspan="5" background="images/inside_01.jpg"> </td>
  </tr>	<tr>
		<td width="44" background="images/bg1.jpg"> </td>
		<td colspan="3">
			<img src="images/inside_03.jpg" width="876" height="171" alt=""><table 
                class="style2">                <br />
                <br />
                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>                <br />
                <br />                <br />
                <tr>                
                    <td class="style4">
                        Tour Title</td>
                                <td class
Tour Title</td>                                <td class="style3" >
                                    <asp:TextBox ID="txttourtitle" runat="server" Width="190"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txttourtitle" ErrorMessage="*"></asp:RequiredFieldValidator>
                                </td>
                            </tr>                            <tr>
                                <td class="style4">
                                    Tour Description</td>
                                <td class="style3">
                                    <textarea id="txttourdesc" cols="20" name="S1" rows="4" class="style3"></textarea>
                                    
                                    </td>
                                                                </tr>
                            <tr>
                                <td class="style4">
                                    Image(64X61)</td>
                                <td>                
                <img  id="img1" src=""  runat="server" alt="" />
                <asp:HiddenField ID="hidWidth" runat="server" />
                <asp:HiddenField ID="hidHeight" runat="server" />
                <input  type="file" id="File1"  runat="server"   önchange="return imageload();" />
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                   ErrorMessage="Upload Jpegs and Gifs only." 
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF)$" 
ControlToValidate="File1"></asp:RegularExpressionValidator>
            </td>                            </tr>
                            <tr>
                                <td class="style4">
                                    Image(398X225)</td>
                                <td>                
                <img  id="img2" src=""  runat="server" alt="" />
                 <asp:HiddenField ID="HiddenField1" runat="server" />
                <asp:HiddenField ID="HiddenField2" runat="server" />
                <input  type="file" id="File2"  runat="server"  önchange="imageload1();" /><asp:RegularExpressionValidator 
                    ID="RegularExpressionValidator2" runat="server" 
                    rrorMessage="Upload Jpegs and Gifs only." 
ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF)$" 
ControlToValidate="File2"></asp:RegularExpressionValidator>
            </td>                            </tr>
                            <tr>
                                <td class="style4">
                                     </td>
                                <td>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">            <contenttemplate>
            <input type="checkbox" id="CheckBox1"  runat="server"  önclick="chkImg()" />
            <asp:Label ID="Label1" Text="For Popular Tour" runat="server"></asp:Label>
                                       </td>            
                                                  </tr>
                            <tr>            <td>
                <br />                 </td>
            <td>                
                <img  id="img3"  runat="server" alt="" style="display:none"/>
                 <asp:HiddenField ID="HiddenField5" runat="server" />
                <asp:HiddenField ID="HiddenField6" runat="server" />
                <input  type="file" id="File3"  runat="server"  önchange="imageload2();" style="display:none"/></td>
        </tr>        <tr>        </contenttemplate>

推荐答案

?)(\\(\ w [\ w].*))(.jpg | .JPG | .gif | .GIF)
?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF)


ControlToValidate ="File1"></asp:RegularExpressionValidator> </td> </tr> < tr> < td class ="style4"> 图像(398X225)< td> < td> < img id ="img2" src =" runat ="server" alt ="/> < asp:HiddenField ID ="HiddenField1" runat ="server"/> < asp:HiddenField ID ="HiddenField2" runat ="server"/> < input type ="file" id ="File2" runat ="server"önchange="imageload1();" />< asp:RegularExpressionValidator ID ="RegularExpressionValidator2" runat =服务器" rrorMessage =仅上传Jpeg和Gif." ValidationExpression ="^(([[a-zA-Z] :) |(\\ {2} \ w +)\
" ControlToValidate="File1"></asp:RegularExpressionValidator> </td> </tr> <tr> <td class="style4"> Image(398X225)</td> <td> <img id="img2" src="" runat="server" alt="" /> <asp:HiddenField ID="HiddenField1" runat="server" /> <asp:HiddenField ID="HiddenField2" runat="server" /> <input type="file" id="File2" runat="server" önchange="imageload1();" /><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" rrorMessage="Upload Jpegs and Gifs only." ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\


?)(\\(\ w [\ w]. *))(.jpg | .JPG | .gif | .GIF)
?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF)


这篇关于如何使用JavaScript在ASP.net中使用复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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