|
-
Oct 26th, 2010, 07:14 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [vs2005] center child window
hi,
im opening a child window by injecting code through gridview rowdatabound.
and also at the same time i wanted to center the child window through the function leftmargin(); but the function does not returning any values when object is triggered.
Code:
DirectCast(e.Row.FindControl("pb_editImage"), Image).Attributes.Add("onclick", "window.open('popup_window.aspx?id=" & e.Row.DataItem("id") & "','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=400px, left=leftmargin();').focus();")
Code:
<script type="text/javascript" >
function leftmargin(){
var a ;
a = (screen.width - width)/2;
return a;
}
</script>
Learn something new every .001 second. 
-
Oct 26th, 2010, 11:13 AM
#2
Re: [vs2005] center child window
You're putting in the call to leftmargin() as part of a string. To have it called as a function, it needs to be outside of the string context:
Code:
DirectCast(e.Row.FindControl("pb_editImage"), Image).Attributes.Add("onclick", "window.open('popup_window.aspx?id=" & e.Row.DataItem("id") & "','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=400px, left='+leftmargin()).focus();")
Also make sure that the "width" variable in your function has a value.
-
Oct 28th, 2010, 03:44 AM
#3
Thread Starter
Fanatic Member
Re: [vs2005] center child window
hey,
the same did not work and it return an error expected ")". heres the markup.
Code:
onclick="window.open('performance_bond.aspx?id=5','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=450px, left='+leftmargin();).focus();"
Learn something new every .001 second. 
-
Oct 28th, 2010, 08:09 AM
#4
Re: [vs2005] center child window
if you look closely, Samba's code does not have the semi-colon you added to leftmargin(). a semi-colon in JavaScript is a line terminator, and you're not terminating that line until you call the focus() method.
-
Oct 30th, 2010, 03:36 AM
#5
Thread Starter
Fanatic Member
Re: [vs2005] center child window
hey,
I remember doing that but it also return an error message WIDTH is undefined. But the markup includes the width property.
Code:
onclick="window.open('performance_bond.aspx?id=5','win_title','menubar=no,status=no,toolbar=no,scrollbars=no,width=540px,height=450px, left='+leftmargin()).focus();"
Learn something new every .001 second. 
-
Oct 30th, 2010, 10:28 AM
#6
Re: [vs2005] center child window
use just numbers; get rid of the "px."
-
Oct 31st, 2010, 04:46 AM
#7
Thread Starter
Fanatic Member
Re: [vs2005] center child window
 Originally Posted by kows
use just numbers; get rid of the "px."
I already do that,regardless of having "px" or not suffix in height and width it works fine. Only that error comes in when I derived left value from function.
And that did not fix the error of undefined width as well.
Thanks.
Learn something new every .001 second. 
-
Oct 31st, 2010, 09:15 AM
#8
Re: [vs2005] center child window
Oh. In your function, you never define width, just like Samba said:
 Originally Posted by SambaNeko
Also make sure that the "width" variable in your function has a value.
-
Nov 1st, 2010, 02:15 AM
#9
Thread Starter
Fanatic Member
Re: [vs2005] center child window
 Originally Posted by kows
Oh. In your function, you never define width, just like Samba said:
OMG I totally miss that.
It seems to work fine now with a fix value in width function.
I did not realize width is not a reserve keyword in js.
Learn something new every .001 second. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|