如何用经典的asp隐藏/显示div

时间:2014-02-04 11:40:20

标签: asp.net

我只想隐藏我的div来自asp脚本这是我的脚本:

<%
        Dim posted = Request.Form("submit")
        If posted = "Submit" Then
            ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            '' Customize the following 5 lines with your own information. ''
            ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            Dim Mail = CreateObject("CDO.Message")
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "easyweb999@gmail.com"
            Mail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "easy@123"
            Mail.Configuration.Fields.Update()
            Mail.Subject = "Software Download"
            Mail.From = "easyweb999@gmail.com"
            Mail.To = Request.Form("v_email") & "," & "easyweb999@gmail.com"
            Dim link As String
            Select Case Request.Form("software")
                Case "EasyOfficeDemoSetup"
                    link = "Set Download Link"
                Case "EasyVATDemoSetup"
                    link = "Set Download Link"
            End Select
            Mail.HTMLBody = "Name : " & Request.Form("v_contact") & "<br/><br/>" & "Company Name : " & Request.Form("vco_name") & "<br/><br/>" & "Address : " & Request.Form("v_address") & "<br/><br/>" & "City : " & Request.Form("v_city") & "<br/><br/>" & "Zip Code : " & Request.Form("zip_code") & "<br/><br/>" & "State : " & Request.Form("state") & "<br/><br/>" & "Country : " & Request.Form("v_country") & "<br/><br/>" & "Telephone No : " & Request.Form("v_phone") & "<br/><br/>" & "Mobile No : " & Request.Form("mobile") & "<br/><br/>" & "Email : " & Request.Form("v_email") & "<br/><br/>" & "Software Download : " & link & "<br/><br/>" & "Remark : " & Request.Form("remark")
            Mail.Send()
            Dim vErr = Err.Description
            If vErr <> "" Then
                Response.Write(vErr & "<br><br>There was an error on this page.")
            Else
                //this is div with id that i want to show/hide
                demo1.Visible = False
                success.Visible = True
                'Response.Write("Thank you, your message has been sent.")
            End If
            Mail = Nothing
        End If
%>

这里我只是放置两个id为demo1的div和成功的runat =“server”所以我可以从asp脚本访问这个div。

3 个答案:

答案 0 :(得分:0)

您可以使用JQuery:

$('#div_id')。show()或$('#div_id')。hide()

或CSS:

.hidden {显示:无}

答案 1 :(得分:0)

试试吧..

<%


    Dim mydiv1, mydiv2

    If (condition) Then
       mydiv1 = "visible"
       mydiv2 = "hidden"
    Else
       mydiv1 = "hidden"
       mydiv2 = "visable"
    End IF

    %>

    <div id="divMyID1" style="visibility:<%=mydiv2%>;">Test1</div>
    <div id="divMyID2" style="visibility:<%=mydiv1%>;"> Test2</div>

答案 2 :(得分:0)

为此,请尝试以下代码:

&#13;
&#13;
For this just try below code:


  <div id="dvshowitem" class="mid-line" style="display:<%=divstyle%>"></div>

  <%
     Dim Itemcount,divstyle
      if Itemcount<6 then
       divstyle ="none"
        else
       divstyle ="block"
        end if
%>

Here 'Itemcount' is number of items and 'dvshowitem' will be hide if item count is less than 6.

 
&#13;
&#13;
&#13;