Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > showModalDialog with an ASP page

Reply
Thread Tools

showModalDialog with an ASP page

 
 
Ralf
Guest
Posts: n/a
 
      11-21-2006
Here is my scenerio and what I am doing. I am open to other ways of
doing this is it makes sense. I have a cell withing a row within a
datagrid. When this cell is clicked (its a date field), I want a
calendar to pop up to change the date. So, I had to added an onclick
event to the cell, which runs a javascript function when it the click
happens. The javascript function does the showModalDialog to open the
Calendar.aspx page and pass in the date field that was in the cell to
prepopulate the calendar control on the new page.

window.showModalDialog('Calendar.aspx',info); //info had the date to
pre-populate

On the new page, how do I get the pre-populated date to my code behind?
I added a HTML button to the modal page and wrote the script to click
the button to activate the event to get into my code behind. But, how
do I get the value 'info' that was passed over to open the dialog
Calendar window? I read where it said to use window.dialogArguments,
but I couldn't get that to work at all, it doesn't recognize it. And
since that is in the javascript, how would I get it to the code behind?

Any insight is appreciated

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXNyZWYgRFVSTkE=?=
Guest
Posts: n/a
 
      11-21-2006
hi,
u could use this basic opensource component or you could do methods by your
self.
http://www.codeproject.com/aspnet/WebModalAnchor.asp

if you want to learn how this component do this job and what you need to do
for making your own modalwindow reed the thinks that i explained to you.

first of all. i want to explain you a silly think that u know about the
modelwindows.
if you open an aspx page which could be posted and reloaded.
the model window lost its properties.
i mean when u refresh the model windows it goes and comes back as a normal
popup window.
you could fix this problem by opening an iframe instead of opening the aspx
page.
like open an iframe page which contains your aspx page.

and now your problem solution.
there is components which does the job which you want. but i get problems
with them so i create my owns and happy with them.
this is the function which you should call from the cell click.
you could create your own argument list.

function fnOpen()
{
var myarguments=new Array();
myarguments[0]=window.self;
myarguments[1]="CID";
myarguments[2]="calender.aspx";
myarguments[3]=650;//width
myarguments[4]=400;//height
var width =myarguments[3];
var height =myarguments[4];
var
cur=window.showModalDialog("ModalblankIframe.htm", myarguments,"statusn;
centern;
helpff;resizable:yes;dialogHeight:"+height+"px;d ialogWidth:"+width+"px;scroll:yes;");

}

// and this is for when the modal window sends the value . it calls this
method.
function setParentReturnValue(returnvalue)
{
//this below line is for clearing and not checking the page validators ex
required page validator etc..
if (typeof(Page_Validators) != "undefined")
{
Page_Validators=new Array();//clearing the validator array
}

//i put an hidden value holder to the page. <input type=hidden id=hdnvalue
runat=server>
document.getEllementById('<%=hdnvalue.ClientID.Tri m()%>').value=returnvalue;

// and i also put an button with style display:none to the page for
submiting the page to this button click event.
//<asp:button id-buttonhidden runat=server style="display:none;"></asp:button>

document.getElementById('<%=buttonHidden.ClientID. Trim()%>').click();
// now you could do every server side operations at this button click event
if you need it.

}

//at the iframe
//which i told you why i use iframe at the begining of my post.

<script language="javascript">
var myarguments=null;

function InitFrame(){
myarguments =window.dialogArguments;
document.getElementById('frContainer').src=myargum ents[2]+"?key="+myarguments[1];
}
</script>
</head>
<body onload="InitFrame();">
<form name="form1" ID="Form1">
<iframe id="frContainer" src="" frameborder="0" height="100%" width="100%">
</iframe>
</form>
</body>
</html>

// and now at your calender.aspx page
when y gona close and want to submit the data to parent
//call the closeandsubmit method with page.registerstartupscript

<script>
function CloseAndSubmit()
{
//hdnreturnvalue is the value which u set at the code behind which u want to
submit to parent.
window.top.myarguments[0].setParentReturnValue(document.getElementById('<%= hdnreturnvalue.ClientID%>').value);
self.close();
}
</script>

--
Esref DURNA
Software Engineer

www.esrefdurna.com
An Asp.Net , C# Turkish Cypriot lover


"Ralf" wrote:

> Here is my scenerio and what I am doing. I am open to other ways of
> doing this is it makes sense. I have a cell withing a row within a
> datagrid. When this cell is clicked (its a date field), I want a
> calendar to pop up to change the date. So, I had to added an onclick
> event to the cell, which runs a javascript function when it the click
> happens. The javascript function does the showModalDialog to open the
> Calendar.aspx page and pass in the date field that was in the cell to
> prepopulate the calendar control on the new page.
>
> window.showModalDialog('Calendar.aspx',info); //info had the date to
> pre-populate
>
> On the new page, how do I get the pre-populated date to my code behind?
> I added a HTML button to the modal page and wrote the script to click
> the button to activate the event to get into my code behind. But, how
> do I get the value 'info' that was passed over to open the dialog
> Calendar window? I read where it said to use window.dialogArguments,
> but I couldn't get that to work at all, it doesn't recognize it. And
> since that is in the javascript, how would I get it to the code behind?
>
> Any insight is appreciated
>
>

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      11-22-2006
The easiest way is to add the info to the url as query parameter, like
Calendar.aspx?info=xxx, and access it from code-behind as
Request.QueryString["info"]


--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]


"Ralf" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> Here is my scenerio and what I am doing. I am open to other ways of
> doing this is it makes sense. I have a cell withing a row within a
> datagrid. When this cell is clicked (its a date field), I want a
> calendar to pop up to change the date. So, I had to added an onclick
> event to the cell, which runs a javascript function when it the click
> happens. The javascript function does the showModalDialog to open the
> Calendar.aspx page and pass in the date field that was in the cell to
> prepopulate the calendar control on the new page.
>
> window.showModalDialog('Calendar.aspx',info); //info had the date to
> pre-populate
>
> On the new page, how do I get the pre-populated date to my code behind?
> I added a HTML button to the modal page and wrote the script to click
> the button to activate the event to get into my code behind. But, how
> do I get the value 'info' that was passed over to open the dialog
> Calendar window? I read where it said to use window.dialogArguments,
> but I couldn't get that to work at all, it doesn't recognize it. And
> since that is in the javascript, how would I get it to the code behind?
>
> Any insight is appreciated
>



 
Reply With Quote
 
Ralf
Guest
Posts: n/a
 
      12-14-2006
OK, I used the QueryString and got the value over no problem.
My new problem is passing the intended value back to the parent page. I
did this on another page, but it was a regular page and not a modal
page. The same thing doesn't work. Before, I was doing

Response.Write("<script>window.opener.parent.__doP ostBack('tbControl','"
+ ddlIntGrpName.SelectedValue + "')</script>")

Which was sending the post back like it was from a control named
tbControl, so I would capture it and get the value that was passed back
with it. Well, with a modal window, window.opener is not longer valid.
This is how I opened the modal window from my parent window. This is
in the jscript, I added this function to the onclick event. It works
great.

<script>function CellClick(info)
{
var changedDate = window.showModalDialog('Calendar.aspx?info=' +
info);
}
</script>

The was this is setup with changedDate being the return, how do I pass
it back to it. Any ideas are appreciated!!

 
Reply With Quote
 
Ralf
Guest
Posts: n/a
 
      12-14-2006
got it.
returnValue='xxxx' in jscript

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to refresh page after calling showModalDialog teddysnips@hotmail.com ASP .Net 1 06-01-2007 01:14 PM
showModalDialog and master page =?Utf-8?B?QXhmb3Jk?= ASP .Net 1 06-02-2006 06:43 PM
REPOST: Need to refresh page after calling showModalDialog teddysnips@hotmail.com ASP .Net 0 01-03-2006 08:11 AM
ok to use file upload in showModalDialog page? Sarah ASP .Net 2 10-18-2005 05:40 AM
Open showModalDialog from showModalDialog Jonathan Javascript 0 07-19-2004 02:30 PM



Advertisments