当我触发按钮单击事件时,我在Ascx页面上有一个按钮,其显示此网页不可用. [英] I Have A Button On Ascx Page When I Am Firing Button Click Event Its Showing This Webpage Is Not Available.

查看:97
本文介绍了当我触发按钮单击事件时,我在Ascx页面上有一个按钮,其显示此网页不可用.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我...

推荐答案

Protected Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
        If fileuploadExcel.HasFile = False Then

            Return
        End If


        Dim filepath As String = Path.GetFullPath(fileuploadExcel.PostedFile.FileName)
        If FormattingHelper.Validateexcelextension(filepath) = " " Then

            Return
        End If

        Dim fileExt As String = Path.GetExtension(fileuploadExcel.PostedFile.FileName).ToLower()
        If fileExt.Equals(".xls") = True Then
        ElseIf fileExt.Equals(".xlsx") = True Then
        Else

            fileuploadExcel.Focus()
            Return
        End If


        'validate file mime-type to check whether its realy a pdf.
        If fileuploadExcel.PostedFile.ContentType.ToLower.Equals("application/vnd.ms-excel") = True Then

        ElseIf fileuploadExcel.PostedFile.ContentType.ToLower.Equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") = True Then

        Else

            fileuploadExcel.Focus()
            Return
        End If

        Dim a As String = ""
        Dim excelpath As String = ""
        Dim filename As String = ""

        Try
            'for localhost path enable this excel path
            excelpath = String.Concat((Server.MapPath("~/temp/" + fileuploadExcel.FileName)))
            fileuploadExcel.PostedFile.SaveAs(excelpath)
            oledbcon = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelpath + ";Extended Properties=Excel 12.0 ")
            oledbcmd = New OleDbCommand("Select * from [Sheet1


",oledbcon) oledbadapter = OleDbDataAdapter(oledbcmd) oledbcon.Open() oledbadapter.Fill(ds) dt = ds.Tables( 0 ) 捕获,例如 As 异常 如果 ex.Message = "
", oledbcon) oledbadapter = New OleDbDataAdapter(oledbcmd) oledbcon.Open() oledbadapter.Fill(ds) dt = ds.Tables(0) Catch ex As Exception If ex.Message = "'Sheet1


'不是有效的名称.请确保它不包含无效字符或标点符号,并且名称不要太长." GetType ]()," " 真实) 其他 ScriptManager.RegisterStartupScript(Page,Page.[ GetType ]()," " ) 结束 如果 最后 如果 oledbcon.State = ConnectionState.打开然后 oledbcon.Close() 结束 如果 结束 尝试 结束
' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long." Then ScriptManager.RegisterStartupScript(Page, Page.[GetType](), "invalidargs", "alert('rename sheetname as sheet1 as given in guidelines');", True) Else ScriptManager.RegisterStartupScript(Page, Page.[GetType](), "invalidargs", "alert('Oops something went wrong.');", True) End If Finally If oledbcon.State = ConnectionState.Open Then oledbcon.Close() End If End Try End Sub


这篇关于当我触发按钮单击事件时,我在Ascx页面上有一个按钮,其显示此网页不可用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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