Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Annoyingly simple problem

Reply
Thread Tools

Annoyingly simple problem

 
 
Mike Chamberlain
Guest
Posts: n/a
 
      03-18-2005
Hi.

Could someone help me with this simple problem?

I'm trying to open a new window from a HyperLink column in my datagrid.
The definition of the column is as follows:
<asp:HyperLinkColumn Text="..."
DataNavigateUrlField="master_id_account"
DataNavigateUrlFormatString="javascript:NewBareWin dow('/Accounts/Edit.aspx?masterIdAccount={0}',
'Account{0}', 750, 550);">
</asp:HyperLinkColumn>

And this emits the following HTML:

<td>
<a
href="javascript:NewBareWindow('/Accounts/Edit.aspx?masterIdAccount=1211482',
'Account1211482', 750, 550);">...</a>
</td>

I have a javascript function NewBareWindow() that wraps the javascript
window.open() function. The above works fine except for one small
problem. The new window opens as expected, but the URL of the original
window also changes, the page displaying just the word "false",
presumably because my NewBareWindow function returns false. If I make
the function return nothing, then [object] is displayed instead of false.

How do I stop the original page changing when the link is clicked? I'm
trying to do this only using the VS.NET Datagrid property builder.
Also, as an experienced web developper, I'm sure I have managed to do
this correctly countless times before, but I can't seem to get it to
work here!

Mike
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      03-18-2005
Hi Mike,

I think you'll have the problem you are seeing until you move your
JavaScript to the onclick event and take it off the href attribute. At least
that's what I noticed the other day.

Let us know?

Ken

"Mike Chamberlain" <> wrote in message
news:...
> Hi.
>
> Could someone help me with this simple problem?
>
> I'm trying to open a new window from a HyperLink column in my datagrid.
> The definition of the column is as follows:
> <asp:HyperLinkColumn Text="..."
> DataNavigateUrlField="master_id_account"
> DataNavigateUrlFormatString="javascript:NewBareWin dow('/Accounts/Edit.aspx?masterIdAccount={0}',
> 'Account{0}', 750, 550);">
> </asp:HyperLinkColumn>
>
> And this emits the following HTML:
>
> <td>
> <a
> href="javascript:NewBareWindow('/Accounts/Edit.aspx?masterIdAccount=1211482',
> 'Account1211482', 750, 550);">...</a>
> </td>
>
> I have a javascript function NewBareWindow() that wraps the javascript
> window.open() function. The above works fine except for one small
> problem. The new window opens as expected, but the URL of the original
> window also changes, the page displaying just the word "false", presumably
> because my NewBareWindow function returns false. If I make the function
> return nothing, then [object] is displayed instead of false.
>
> How do I stop the original page changing when the link is clicked? I'm
> trying to do this only using the VS.NET Datagrid property builder. Also,
> as an experienced web developper, I'm sure I have managed to do this
> correctly countless times before, but I can't seem to get it to work here!
>
> Mike


 
Reply With Quote
 
 
 
 
Mike Chamberlain
Guest
Posts: n/a
 
      03-20-2005
Hi Ken,

Indeed that is the case, but unfortunately I don't think that the
HyperLink column supports the onclick attribute. I was trying to avoid
having to write any more code.

Mike

Ken Cox [Microsoft MVP] wrote:
> Hi Mike,
>
> I think you'll have the problem you are seeing until you move your
> JavaScript to the onclick event and take it off the href attribute. At
> least that's what I noticed the other day.
>
> Let us know?
>
> Ken
>
> "Mike Chamberlain" <> wrote in message
> news:...
>
>> Hi.
>>
>> Could someone help me with this simple problem?
>>
>> I'm trying to open a new window from a HyperLink column in my
>> datagrid. The definition of the column is as follows:
>> <asp:HyperLinkColumn Text="..."
>> DataNavigateUrlField="master_id_account"
>> DataNavigateUrlFormatString="javascript:NewBareWin dow('/Accounts/Edit.aspx?masterIdAccount={0}',
>> 'Account{0}', 750, 550);">
>> </asp:HyperLinkColumn>
>>
>> And this emits the following HTML:
>>
>> <td>
>> <a
>> href="javascript:NewBareWindow('/Accounts/Edit.aspx?masterIdAccount=1211482',
>> 'Account1211482', 750, 550);">...</a>
>> </td>
>>
>> I have a javascript function NewBareWindow() that wraps the javascript
>> window.open() function. The above works fine except for one small
>> problem. The new window opens as expected, but the URL of the
>> original window also changes, the page displaying just the word
>> "false", presumably because my NewBareWindow function returns false.
>> If I make the function return nothing, then [object] is displayed
>> instead of false.
>>
>> How do I stop the original page changing when the link is clicked?
>> I'm trying to do this only using the VS.NET Datagrid property builder.
>> Also, as an experienced web developper, I'm sure I have managed to do
>> this correctly countless times before, but I can't seem to get it to
>> work here!
>>
>> Mike

>
>

 
Reply With Quote
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      03-20-2005
Hi Mike,

Were you able to make it work that way?

Ken


"Mike Chamberlain" <> wrote in message
news:...
> Hi Ken,
>
> Indeed that is the case, but unfortunately I don't think that the
> HyperLink column supports the onclick attribute. I was trying to avoid
> having to write any more code.
>
> Mike


 
Reply With Quote
 
Mike Chamberlain
Guest
Posts: n/a
 
      03-21-2005
Yes, after much coercion:
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink Runat="server" href="javascript:void(0);"
onclick='<%# MakeOpenAccountWindowJS(DataBinder.Eval(Container. DataItem,
"master_id_account")) %>'>...</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>

It took me ages to work out that the onclick needs to be in SINGLE
quotes. Thanks for your help.

Mike



Ken Cox [Microsoft MVP] wrote:
> Hi Mike,
>
> Were you able to make it work that way?
>
> Ken
>
>
> "Mike Chamberlain" <> wrote in message
> news:...
>
>> Hi Ken,
>>
>> Indeed that is the case, but unfortunately I don't think that the
>> HyperLink column supports the onclick attribute. I was trying to
>> avoid having to write any more code.
>>
>> Mike

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ReportViewer web page annoyingly jumps when user drills down into data dbuchanan ASP .Net 1 06-20-2008 09:23 AM
Simple VB.Net / webservice requirement (but not simple for me....) Dave E ASP .Net 7 01-11-2006 02:07 PM
Re: Simple Simple question!!! Kevin Spencer ASP .Net 0 06-25-2004 05:25 PM
Re: Simple Simple question!!! ashelley@inlandkwpp.com ASP .Net 0 06-25-2004 04:18 PM
Simple problem with a simple chat script dillon Javascript 1 11-17-2003 11:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57