Permission denied error ASP.Net Vsual studio

C

Colin Graham

I am working with a piece of javascript that i have inherited from
another developer. It is for a date picker function and it runs fine
locally but i get an error when i deploy it on the server and run it.
Can anyone help me with my issue i get a permission denied error also
when the error begins.
i get the error on the folowing part of the codee:

window.opener.Form1.txtDate.value = '05/10/2004'

The complete line of code is

<script language="javascript">window.opener.Form1.txtDate.value =
'05/10/2004';window.close();
 
G

Grant Wagner

Colin said:
I am working with a piece of javascript that i have inherited from
another developer. It is for a date picker function and it runs fine
locally but i get an error when i deploy it on the server and run it.
Can anyone help me with my issue i get a permission denied error also
when the error begins.
i get the error on the folowing part of the codee:

window.opener.Form1.txtDate.value = '05/10/2004'

The complete line of code is

<script language="javascript">window.opener.Form1.txtDate.value =
'05/10/2004';window.close();

You can't set the value of a form element in another window. The solution
to this is to create a function in the opener that does the setting, then
invoke that from the opened window:

-- in the opener --

<script type="text/javascript">
function setFormValue(formName, elementName, value) {
document.forms[formName].elements[elementName].value = value;
}
</script>

-- in the opened window --
<script type="text/javascript">
opener.setFormValue('Form1', 'txtDate', '05/10/2004');
window.close();
</script>
 
L

lawrence

Grant Wagner said:
You can't set the value of a form element in another window. The solution
to this is to create a function in the opener that does the setting, then
invoke that from the opened window:

-- in the opener --

<script type="text/javascript">
function setFormValue(formName, elementName, value) {
document.forms[formName].elements[elementName].value = value;
}
</script>

-- in the opened window --
<script type="text/javascript">
opener.setFormValue('Form1', 'txtDate', '05/10/2004');
window.close();
</script>

Forgive the ignorant question, but in this last script, I see you use
opener as some kind of global. Is it built into the DOM? One can use
it in a script and assume it always exists?
 
C

Colin Graham

-- in the opened window --
<script type="text/javascript">
opener.setFormValue('Form1', 'txtDate', '05/10/2004');
window.close();
</script>

in the code above i need to change the '05/10/2004' part to a value of
a variable pulled in from the calendar form. how can i do this as the
value is pulled in in the folowing code in a sub.

Private Sub Calendar1_SelectionChanged(sender As Object, e As
System.EventArgs)
Dim strjscript as string '= "<script language=""javascript"">"
strjscript = strjscript & "window.opener." &
Httpcontext.Current.Request.Querystring("formname") & ".value = '" &
Calendar1.SelectedDate & "';window.close();"
strjscript = strjscript & "</script" & ">" 'Don't Ask, Tool
Bug
Literal1.text = strjscript
End Sub




C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top