RE: showModalDialog with an ASP page

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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,"status:on;
center:on;
help:off;resizable:yes;dialogHeight:"+height+"px;dialogWidth:"+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.Trim()%>').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=myarguments[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


.



Relevant Pages

  • replacing built in keyboard shortcuts with my macros?
    ... On the macros window, if you click Options for a given macro, Excel ... Note If an action you use often does not have a shortcut key, ... CTRL+) Unhides any hidden columns within the selection. ... CTRL+* Selects the current region around the active cell (the data area ...
    (microsoft.public.excel.programming)
  • Re: InValidateRect API not working as expected !
    ... the workbook window will obviously throw all the dimensions out. ... the gradient to the top left corner of app window and the blend to the ... Dim BF As BLENDFUNCTION, lBF As Long ... I have an Excel worksheet with a Source Cell and a Target Cell. ...
    (microsoft.public.excel.programming)
  • Re: Freezing the cell (with Random formula)
    ... Close the window. ... typing "MyRand". ... the value of the original cell changes. ... > procedures for entering a macro, ...
    (microsoft.public.excel.misc)
  • Re: auto bold partial text in a string
    ... The macro is triggered by a worksheet change (e.g. entering a value into some ... I pasted it into the window as instructed but nothing happened... ... string be in the cell. ... Dim dSum As Double ...
    (microsoft.public.excel.misc)
  • Re: Need help on how to send a variable value from an Iframe back to its parent?
    ... > var varborderfromiframe = window.Iframemain.y; ... > I'll guess that window.Iframemain is an attempt to reference an iFrame ... To get a reference to it from the parent ... > This infers that your script is in the parent window, ...
    (comp.lang.javascript)