如何在相同aspx页面的新窗口中显示最大化的gridview? - javascript

我在一个aspx页面中有一个fileupload控件,按钮控件和一个gridview控件。单击按钮控件后,是否可以在新的最大化窗口中单独显示GridView控件?

参考方案

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImageViewForm.aspx.cs" Inherits="WebApplication1.ImageViewForm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="js/jquery-1.10.1.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            var urlforpdf = document.getElementById("<%=hdnurl.Value%>");
            var data = $("#hdnurl").val();
            if (data != null & data != "" & data != undefined) {
                $("#pdfurl").css("display", "block");
                $("#pdfurl").attr("src", data);
                //alert($("#hdnurl").val());
            }
            else {
                $("#pdfurl").css("display", "none");
            }

        });

    </script>
</head>


<body>
    <style>
        .Uplaod {
            margin-left: 479px;
            height: 36px;
            width: 19%;
            background-color: dimgrey;
            color: white;
            font-size: 16px;
            border: 1px solid #333;
        }
    </style>
    <form id="form1" runat="server">
        <br />
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <br />
        <div style="text-align: center; width: 1024px; margin: 0 auto;">
            <br />
            <label style="font-weight: 700; font-size: 50px;">Tennis Result</label>
            <table width="50%" cellpadding="2" cellspacing="0">
                <br />
                <tr>
                    <br />
                    <td style="margin-left: 53%; width: 20%">
                        <br />
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
                        </asp:UpdatePanel>
                        <br />
                    </td>
                    <td>
                        <asp:Image ID="imgViewFile" runat="server" Style="height: 500px; border: 10px solid #928F8F; border-radius: 15px; margin: 0 auto" />
                    </td>

                </tr>
            </table>
            <input type="hidden" runat="server" id="hdnurl" name="name" value="" />
            <iframe style="display: none; height: 600px; width: 1000px; border: 10px solid #928F8F; border-radius: 15px;" id="pdfurl"></iframe>
            <br />
        </div>
        <br />
    </form>
</body>
</html>


**C# CODE**

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class ImageUploadForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // if (FileUpload1.HasFile)
            //{
            //    FileUpload1.SaveAs(MapPath("~/TEST/" + FileUpload1.FileName));
            //   imgViewFile.ImageUrl = "~/TEST/" + FileUpload1.FileName;
            //}

            imgViewFile.Style.Add("display", "none");
        }
        protected void btnUpload_Click(object sender, EventArgs e)
        {

            string[] validFileTypes = { "bmp", "gif", "png", "jpg", "jpeg", "pdf" };
            string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
            bool isValidFile = false;

            if (FileUpload1.HasFile)
            {
                for (int i = 0; i < validFileTypes.Length; i++)
                {
                    if (ext == "." + validFileTypes[i])
                    {
                        isValidFile = true;
                        break;
                    }
                }
                if (!isValidFile)
                {
                    Label1.ForeColor = System.Drawing.Color.Red;
                    Label1.Text = "Invalid File. Please upload a File with extension " +
                                   string.Join(",", validFileTypes);
                }
                else
                {
                    Label1.ForeColor = System.Drawing.Color.Green;
                    Label1.Text = "File uploaded successfully.";
                }
                string dirUrl = "TEST1" + this.Page.User.Identity.Name;
                string dirPath = Server.MapPath(dirUrl);
                // string fileName = Path.GetFileNameWithoutExtension(dirPath);
                // string dirPath = AppDomain.CurrentDomain.BaseDirector


                if (!Directory.Exists(dirPath))
                {
                    Directory.CreateDirectory(dirPath);
                }
                string[] filePaths = Directory.GetFiles(dirPath);
                foreach (string filePath in filePaths)
                    File.Delete(filePath);
                //var ok = Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories)

                //.ToList();

                // save the file to the Specifyed folder  

                string fileUrl = dirUrl + "/" + Path.GetFileName(FileUpload1.PostedFile.FileName);
                FileUpload1.PostedFile.SaveAs(Server.MapPath(fileUrl));
                string exten = Path.GetExtension(FileUpload1.PostedFile.FileName);
                //Display the Image in the File Upload Control  

                imgViewFile.ImageUrl = fileUrl;
                imgViewFile.Style.Add("display", "block");

                if (exten == ".pdf")
                {
                    hdnurl.Value = "../" + fileUrl;
                    //pdfurl.Visible = true;
                    imgViewFile.Style.Add("display", "none");
                }
                else
                {
                    hdnurl.Value = null;
                }

                //Session["Imagename"] = FileUpload1.FileName;
            }

        }

    }
}

在提交时在表单操作中获取变量丢失 - javascript

            当表单由onchange事件提交时,它不会保留get变量view。任何想法为什么会发生这种情况?提交后,这是它进入的网址,index?month=February&year=2014<form action="index?view=list" class="pure-form pure-fo…

选择后显示输入元素 - javascript

我有一个表格,其中取决于用户的选择,输入元素是否可见。实际上,用户正在以另一种形式设置已定义的合作伙伴类型,并且如果选中该元素,则允许在该类型的合作伙伴上可见的元素类型1将显示以下元素:<input type="text" id="partner" name="partner" class=&…

JavaScript将PHP中的字符串和整数传递给函数 - javascript

我正在尝试将字符串和整数都传递到同一函数中,但是引号引起了问题。我发现错误出在echo $q->info部分,我必须在此代码上使用双引号。有人可以帮我写这个$q->info,但不能获得真正的价值吗?到目前为止,我的代码是<td><a href="javascript:add(<?php echo $q->i…

将Web用户控件添加到页面时,asp按钮onclick不会触发 - javascript

我正在使用使用Visual Studio模板创建的Web表单应用程序。模板具有一个内容占位符,该占位符被访问的任何页面的内容替换。有问题的页面有几个服务器控件,例如文本框,标签和按钮。当我单击我的更新按钮时,它可以正常工作,这些值会回传并更新数据库。我想在所有子页面上创建通用的登录提示。我的导航栏(位于我的母版页中)具有引导程序设置。我在导航栏中添加了一个下…

Telerik单选按钮所需的字段验证器 - javascript

如何设置Telerik单选按钮所需的字段验证器?我想在按钮单击“ BtnSave”上设置必填字段验证器吗?请帮忙!<telerik:RadButton ID="radio_male" runat="server" ToggleType="Radio" AutoPostBack="fa…