Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.Net Popup with DataNavigateURLFields

Status
Not open for further replies.

Marchello2004

Technical User
Sep 29, 2005
12
GB
Hi

This is really bugging me now...

I'm trying to get this opened in a pop up using the following code...

<asp:HyperLinkField HeaderText="Popup" Text="View" NavigateUrl="javascript:window.open('teaching.aspx?Staff_ID={0}',,'width=640 height=500');" />

But this won’t do a thing. Staff_ID is not even picking up the right data from the link.

This is what the original link code looks like but obviously without the popup effect...

<asp:HyperLinkField DataNavigateUrlFields="Staff_ID" DataNavigateUrlFormatString="teaching.aspx?Staff_ID={0}" HeaderText="Details" Text="View" />

Adding DataNavigateUrlFields="Staff_ID" to the popup code will send me to the completely wrong address

Any ideas where I’m going wrong here?
 
the popup window has to have a name
Code:
<asp:HyperLinkField HeaderText="Popup" Text="View" NavigateUrl="javascript:window.open('teaching.aspx?Staff_ID={0}',[COLOR=blue]'PopUp'[/color],'width=640 height=500');" />

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hello

Hey that's great, thanks for that. I got that working. The problem is that Staff_ID is not being passed form one page to the other...

The resulting address for the popup page should be...

.../teaching.aspx?Staff_ID=g0000100

but instead I get...

.../teaching.aspx?Staff_ID = {0}

So what do I need to do to get the Staff_ID placed in there? Surely it can't be that difficult.

Thank you for your help. Much appreciated...
 
Code:
<asp:HyperLinkField HeaderText="Popup" Text="View" [COLOR=blue]DataNavigateUrlFormatString[/color]="javascript:window.open('teaching.aspx?Staff_ID={0}','PopUp','width=640 height=500');" />

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
No, I've tried that many times and it doesn't work at all...

Anyway, I wasn't even close to the solution. In the end, this is the code I added...

<script language=javascript>
function openPopup(strOpen)
{
//alert(strOpen);
open(strOpen, "Teaching", "status=1, width=640 height=500, scrollbars=1");
}
function Checkbox1_onclick() {

}

</script>

…and then where the link goes...

<asp:TemplateField>
<ItemTemplate>

<a href="javascript:eek:penPopup('teaching.aspx?Staff_ID=<%# Eval("Staff_ID") %>')"> More... </a>

</ItemTemplate>
</asp:TemplateField>

And it has to be within the <asp:TemplateField> <ItemTemplate> tags because otherwise the popup will be blocked. I simply can not believe is that hard to build a popup link… I thought Microsoft was making things easier...!?

Kind regards…

MQD
 
I simply can not believe is that hard to build a popup link… I thought Microsoft was making things easier...!?
It isn't difficult at all to open a new browser window, and it's especially easy with a HyperLinkField. I always find it quite ironic when developers blame Microsoft for something then don't understand yet continue to use their product. Just because you haven't been able to read through the help files and understand how to implement something doesn't mean it's hard to do.

If you really have to use a pop-up, which I would say you don't especially as the W3 standards are depreciating attributes such as the target, then don't try to force your users to use a browser without some of it's capabilities. Pick a DOCTYPE that will let you use the target attribute and use somethign like this:
Code:
<asp:hyperlinkfield datatextfield="Staff_ID" datanavigateurlfields="Staff_ID"  datanavigateurlformatstring="~\teaching.aspx?Staff_ID={0}" headertext="Price" target="_blank" />


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top