Dean,
I am confused on what goes in my NavigateUrl property on my Hyperlink control.
-------------- Original message --------------
From: "Dean Fiala" <[EMAIL PROTECTED]>
You could do this in row command, but why? There is nothing interactive you
are getting from the user .The l1 Label must be set when you bind the grid,
so you already have your ProductID then.
Let's simply this some more. Why pass the dates in the URL? You are
reading them from session objects anyway, why not just read them in the pop
up page?
So, what'd I do, is toss away the RowCommand, stop passing the dates, and do
this...
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.GridViewRowEventArgs) Handles
GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim PopupHeight As Integer = 400
Dim PopupWidth As Integer = 400
Dim drv As DataRowView = e.Row.DataItem
Dim PopUpURL As String = "CustomerDetails.aspx?ProductID=" &
drv("ProductID")
Dim hl As HyperLink = e.Row.FindControl("MyJavascriptHyperLink")
hl.NavigateUrl = String.Format("javascript:popUp('{0}', {1},
{2});", PopUpURL, PopupHeight, PopupWidth)
End If
End Sub
Just get it so you can call the javascript function, then go in an add in
your other parameters for Top and Left to the javascript function and update
the hyperlink's NavigateUrl appropriately.
On 9/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Dean,
>
> Ok, I've tried what yo usaid but I seem further away from getting what I
> want. I'm totally confused now. Here is my code:
>
>
> Dim PopupHeight As Integer = 400
> Dim PopupWidth As Integer = 400
> 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)
>
> l1.text is underlined obviously, since it is not defined. In my code that
> was working I had this code:
>
> Private Sub gvProducts_RowCommand(ByVal sender As Object, ByVal e As
> GridViewCommandEventArgs) Handles gvProducts.RowCommand
> Select Case e.CommandName
> Case "Customers"
> Dim objGridRow As GridViewRow = DirectCast(DirectCast(e.CommandSource,
> LinkButton).NamingContainer, GridViewRow)
> Dim l1 As Label = objGridRow.FindControl("ProductID")
> Dim l2 As Label = objGridRow.FindControl("Descript")
> Session("Descript") = l2.Text
> ClientScript.RegisterStartupScript(GetType(String), "", "<script
> language=""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>")
> End Select
> End Sub
>
> I was using the RowCommand instead of the RowDataBound. You can see where
> I dimmed a GridRow object and label to get the value of l1. This does not
> work with the RowDataBound event. Maybe I need some different syntax but I
> was unable to find it.
>
>
> -------------- Original message --------------
> From: "Dean Fiala" <[EMAIL PROTECTED] <dfiala%40gmail.com>>
> 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] <rherrmann05%40comcast.net> <
> [EMAIL PROTECTED] <rherrmann05%40comcast.net>> 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] <dfiala%40gmail.com>>
> >
> > 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><rherrmann05%40comcast.net> <
> [EMAIL PROTECTED] <rherrmann05%40comcast.net>
> <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><
> > 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><rherrmann05%40comcast.net>
> > > <
>
> >
> > > [EMAIL PROTECTED]
> > > <rherrmann05%40comcast.net><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]
>
> [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]
[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/