Step 1. Put the function in your ASPX page
<script language="javascri[pt">
function popUp(url, width, height) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width='
+ width + ',height=' + height);
self.name = "mainWin";
}
</script>
or better yet, put it in a javascript file and reference it in your page,
which will let you easily reuse it.
<script language=javascript src="/scripts/common.js"
type=text/javascript></script>
Step 2. Change the LinkButton to Hyperlink.
Step 3. Add some code to RowDataBound event to set the NavigateUrl on the
hyperlink when you bind the grid
Dim PopupHeight as Integer = 100
Dim PopupWidth as Integer = 100
Dim PopUpURL as String = "CustomerDetails.aspx?ProductID=" & l1.Text &
"&StartDate>=" & Session("StartDate") & "&EndDate<=" & Session("EndDate")
Dim hl as Hyperlink = e.Row.FindControl("MyJavascriptHyperLink")
hl.NavigateUrl = String.Format("javascript:popUp('{0}', {1}, {2});",
PopUpURL, PopUpHeight, PopUpWidth)
That's it. When you click on the link it will call the javascript function.
You can do a lot of fun stuff with javascript, it's a very handy tool to
have in yoru bag of tricks.
On 9/13/06, [EMAIL PROTECTED] < [EMAIL PROTECTED]> wrote:
>
> I understand what you are saying about using a javascript function but I
> am very weak in javascript. I have no clue how call this function and pass
> in the url, width, height, etc parameters.. I'm not sure where this
> function goes. I assume in the html but where? Presently, I use a
> LinkButton control embedded in a Gridview control. When clicked, I use the
> method called by the CommandName to run the RegisterStartupScript. Not
> sure how to call this function you provided me now.
>
>
> -------------- Original message --------------
> From: "Dean Fiala" < [EMAIL PROTECTED]>
>
> Get yourself a copy of the javascript bible.
>
> http://www.amazon.com/JavaScript-Bible-Fifth-Danny-Goodman/dp/0764557432/sr=8-1/qid=1158157281/ref=pd_bbs_1/103-2982630-1495037?ie=UTF8&s=books
> Easily worth $35.
>
> You only have one argument here, the formatting ends up in the URL, so it
> doesn't get passed along to the window optiosn.
>
> Make your life easier and call a custom javascript function. This is one I
> use...
>
> function popUp(url, width, height) {
> sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width='
>
> + width + ',height=' + height);
> self.name = "mainWin";
> }
>
> You can add in the top and left parameters, or hardcode t hem in the
> script.
>
>
> On 9/13/06, [EMAIL PROTECTED] <rherrmann05%40comcast.net> <[EMAIL
> PROTECTED]<rherrmann05%40comcast.net>>
> wrote:
> >
> > Peter,
> >
> > Here is the view source for my javascript:
> >
> > <script language="JavaScript">PopupWindow=window.open('
> > CustomerDetails.aspx?ProductID=26290&StartDate>=1/1/2004&EndDate<=3/31/2005,
> > width=500,height=280,top=300,left=100');PopupWindow.focus();</script>
> > <script type="text/javascript">
> >
> > Yes, I'm sure it's some bad syntax. My problem is that I no little about
> > the proper syntax for this type of javascript. Maybe you can see what's
> > wrong with it.
> >
> > Thanks,
> > Bob
> >
> >
> > -------------- Original message --------------
> > From: "Peter Br unone" <[EMAIL PROTECTED]<peter.brunone%40gmail.com><
> peter.brunone% 40gmail.com>>
> >
> > What does the script look like when you right-click the page and select
> > View Source? You may just have an errant comma or quote in that mess of
> > concatenation (happens to everybody)...
> >
> > Cheers,
> >
> > Peter
> >
> > On 9/12/06, [EMAIL PROTECTED]
> > <rherrmann05%40comcast.net><rherrmann05%40comcast.net> <
>
> > [EMAIL PROTECTED] <rherrmann05%40comcast.net><rherrmann05%40comcast.net>>
> > wrote:
> > >
> > >
> > > Hi all,
> > >
> > > I am using the following code to produce a popup window when the user
> > > clicks a button. I am using VS 2.0:
> > > ClientScript.RegisterStartupScript (GetType(String), "", "<script
> > > l anguage=""JavaScript"">" & _
>
> > > "PopupWindow=window.open('" & "CustomerDetails.aspx?ProductID=" &
> > l1.Text& "&StartDate>=" & Session("StartDate") & "&EndDate<=" &
> > Session("EndDate")
> > > & ", width=500,height=280,top=300,left=100" & "');" & "
> PopupWindow.focus
> > > ();</script>")
> > >
> > > The popup window does appear. But I want to make the size of the
> window
> > > smaller and i want to center the page. It appears as though the width,
> > > height, and top is not working properly. It just ignores whatever I
> put
> > in
> > > the above statement. Does anyone know what I am doing wrong?
> > >
> > > Thanks,
> > > Bob
> > >
> >
> > [Non-text portions of this message have been removed]
> >
> > [Non-text portions of this message have been remov ed]
> >
> >
> >
>
> --
> Dean Fiala
> Very Practical Software, Inc
> Now with Blogging...
> http://www.vpsw.com/blogbaby
> Microsoft MVP
>
> [Non-text portions of this message have been removed]
>
>
>
--
Dean Fiala
Very Practical Software, Inc
Now with Blogging...
http://www.vpsw.com/blogbaby
Microsoft MVP
[Non-text portions of this message have been removed]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNet2/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/AspNet2/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/