pass parameters to popup window with showModalDialog +aspx

21 Nov

Write this code at Header

function Popup() {

var x = document.getElementById(‘<%=txtRegIDS.ClientID %>’).innerText;

//For showModalDialog Popup Window
window.showModalDialog(“view-student-edu-doc.aspx?param1=” + x, null, ‘status:no;dialogWidth:770px;dialogHeight:500px;dialogHide:true;help:no;scroll:no’)

//For Simple Popup Window
//“view-student-edu-doc.aspx?param1=” + x, ‘window’, ‘width=780,height=620,menubar=no, resizable=no,scrollbars=no,left=280,top=250’)


//Html Code

<asp:Button id=”Button1″ Text=”Student Document” OnClientClick=”Popup()” runat=”server” />
<div style=”visibility:hidden”> <asp:Label ID=”txtRegIDS” runat=”server”   ></asp:Label></div>

//Get this Parm value to another Page with querystring and load the specific information

protected void Page_Load(object sender, EventArgs e)
if (!IsPostBack) {
if (Request.QueryString[“param1”] != null && Request.QueryString[“param1”] != string.Empty)
int ID = Convert.ToInt32(Request.QueryString[“param1”].ToString());

public void gvStdDocument(int RegID)

DataSet ds = DALCourseRequirdDocument.GetStudentEduDoc(RegID);

if (ds != null && ds.Tables[0].Rows.Count > 0)
gv.DataSource = ds;
//    //gvDocmentdetail


//The gridview data of Popup window

<asp:GridView ID=”gv” runat=”server” AutoGenerateColumns=”False” Width=”100%” DataKeyNames=”CRD_ID,doc_uploadID”
PageSize=”50″ EmptyDataText=”No record found” CellPadding=”4″ GridLines=”None”>
<HeaderStyle CssClass=”grid_head” />
<RowStyle CssClass=”data_set1″ />
<AlternatingRowStyle CssClass=”data_set1″ />
<asp:TemplateField HeaderText=”Name” ItemStyle-HorizontalAlign=”left”>
<asp:HiddenField ID=”hdID” runat=”server” Value='<%# Eval(“CRD_ID”) %>’ />
<ItemStyle HorizontalAlign=”Left”></ItemStyle>
<asp:BoundField DataField=”CreatedDate” HeaderText=”Date Date” SortExpression=”ModifiedDate”
DataFormatString=”{0:d}” />
<asp:BoundField DataField=”ModifiedDate” HeaderText=”Upload Date” SortExpression=”ModifiedDate”
DataFormatString=”{0:d}” />
<asp:TemplateField HeaderText=”Actions” ItemStyle-HorizontalAlign=”Left” ItemStyle-Width=”40px”>
<asp:ImageButton ID=”ImageButton1″ runat=”server” CommandArgument='<%# Eval(“UploadedDocument”) %>’
ImageUrl=”~/images/Download.jpg” CausesValidation=”False” OnClick=”ImageButton1_Click” />
<ItemStyle />

/// For Download Code

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
string _Name = ((ImageButton)sender).CommandArgument;
protected void DownloadFile(string name)

string folderPath = ConfigurationManager.AppSettings.Get(“DocumentPath”) + name; ;

string docPath = Request.PhysicalApplicationPath + folderPath;

System.IO.FileInfo _file = new System.IO.FileInfo(docPath);
if (_file.Exists)
Response.AddHeader(“Content-Disposition”, “attachment; filename=” + _file.Name);
Response.AddHeader(“Content-Length”, _file.Length.ToString());
Response.ContentType = “application/octet-stream”;
//    ClientScript.RegisterStartupScript(Type.GetType(“System.String”), “messagebox”, “&lt;script type=\”text/javascript\”&gt;alert(‘Sorry no image found’);</script>”);


Posted by on November 21, 2010 in ASP Dot Net C#


7 responses to “pass parameters to popup window with showModalDialog +aspx

  1. Hitesh

    April 7, 2011 at 6:39 am

    in this line DALCourseRequirdDocument.GetStudentEduDoc(RegID);

    what ” DALCourseRequirdDocument ” stands for?

    • humrahimcs

      April 7, 2011 at 6:54 am

      Thanx for comment…
      which is object class where we get the data from database.
      you can also get data directly from database through Select Query and save in Dataset and pass here dataset to Control.

      Sajjad ahmed

    • humrahimcs

      April 7, 2011 at 6:55 am

      If you feel more difficulty then tell me i try to help you

  2. Hitesh

    April 8, 2011 at 5:25 am


    my question is

    i have displayed data in data grid and when i click on edit link i want to popup a window in which value of that row can be display in textbox that is on pop up form.

    So can you help me for that..?


  3. Hitesh

    April 9, 2011 at 9:34 am

    Thanks ,

    Its works good.

  4. Hitesh

    April 9, 2011 at 9:39 am

    now i m implementing more ..

    when i click on Edit button popup window open..ok in my form i upload a image and save it in my project folder.

    problem was when i click on edit button of grid i can’t get image from that folder related to that record …

    is there any way to implement that way??? try to give that if possible…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: