CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 1/17/2007 3:29:46 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 8 Views: 22 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
9 Items, 1 Pages 1 |< << Go >> >|
mlasell
Asp.Net User
programatically add javacsipt link to every PDF on site?1/17/2007 3:29:46 PM

0/0

Hello,

I am trying to use Webtends MultiTrack functionality to track the downloading of all PDFs on a site.

This looks like a major maintenance problem, since each pdf link on the site will need special code added to it, and new ones get added regularly, so a web production person would have to very carefully add code each time- something I would like to avoid.

Is there a way to use code-behind at the Masterpage level to programatically add the code to any Hyperlink whose NavigateUrl includes ".pdf". I have changed Hyperlinks in code-behind, but not universally for the site.

Thanks,

Michael

tfsmag
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/17/2007 5:07:59 PM

0/0

if you are using server controls to create the links it should be possible? for instance if  you used a asp:hyperlink you could do this in the page_load

        If InStr(HyperLink1.NavigateUrl, ".pdf") Then
            HyperLink1.NavigateUrl = HyperLink1.NavigateUrl & "extra_string_goes_here"
        End If

 
 


------------------------------------------------
Jeff Turner (simpleModus)

Don't forget to mark the correct answer for your
question to help out future visitors!
tfsmag
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/17/2007 5:19:18 PM

0/0

oops, didn't read thoroughly enough  :)

 for doing it on the masterpage level that might be a little tougher.

 
maybe try somethign like this

        For i As Integer = 0 To Page.Master.Controls.Count - 1

        'check the type of Page.Master.Controls(i) here and then check the navigateurl value of each hyperlink
 


        Next

 


------------------------------------------------
Jeff Turner (simpleModus)

Don't forget to mark the correct answer for your
question to help out future visitors!
mlasell
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/17/2007 5:19:20 PM

0/0

Thanks! That makes sense.

Michael

mlasell
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/17/2007 10:28:35 PM

0/0

Do you have any more ideas on this subject? I work in C#.

It turns out that Master.Controls does not find controls that aren't in the masterpage. But even if I go down a level into the content pages, I can't figure out how to discover whether a control is a HyperLink

<

script runat="server">
     protected void Page_PreInit() {
     for (int i=0; i < (Page.Controls.Count - 1); i++)
     {
        Response.Write(Page.Controls[i].ToString() + "<br />");
     }
</script>

 returns only "System.Web.UI.LiteralControl" even though there is a <asp:HyperLink> in the page.

I think I am missing some concept here.

Thank, Michael

 

Zhao Ji Ma - MS
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/22/2007 7:12:48 AM

0/0

Hi,

The control might be child control of the Page, and it might be grandchild control too..., e.g.

Page

+ ---- HyperLink

+ ---- PlaceHolder

        + ---- HyperLink

mlasell:

<script runat="server">
     protected void Page_PreInit() {
     for (int i=0; i < (Page.Controls.Count - 1); i++)
     {
        Response.Write(Page.Controls[i].ToString() + "<br />");
     }
</script>

 returns only "System.Web.UI.LiteralControl" even though there is a <asp:HyperLink> in the page.

The method only list all of the child control, you need iterate all of them, child, grandchild, grandgrandchild.

 

hope it help!


Zhao Ji Ma
Sincerely,
Microsoft Online Community Support

?Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ?
Leijun Jie - MS
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/26/2007 7:33:46 AM

0/0

There is a good article about master page:
ASP.Net 2.0 - Master Pages: Tips, Tricks, and Traps

The future is now...
Sincerely,
LeiJun Jie
Microsoft Online Community Support
mlasell
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/29/2007 8:39:41 PM

0/0

Thanks to you helpful people.

 Here is what I got to work on an individual page. It loops through all the image buttons and sets some standard javascript made unique by using the ClientID and also the CommandArgument of each button.Thus the page editor person who wants to add or change a link only has to assign a unique id and put in the PDF location in the CommandArgument without understanding much else. However my original problem still remains. How do I add this to the masterpage code-behind to get it to change every ImageButton on the site? I don't want to have to add a Panel to each page that has PDF links, and I don't want to add it to the code-behind of each page. So I want to add it to every ImageButton control in ContentPlaceHolder "Main"

Thanks for any more help.

In the page/panel a list of these:

<

asp:ImageButton id="ImageButton2" runat="server" CommandArgument="/PDFs/001Brochure.pdf"></asp:ImageButton>

in the cs file:

 protected void Panel1_OnLoad(object sender, EventArgs e)

{

       Panel Panel1 = (Panel)sender;

        for (int i = 0; i < (Panel1.Controls.Count - 1); i++)

        {

              ImageButton link = Panel1.Controls[i] as ImageButton;

               if (link != null)

               {

                link.ImageUrl = "/images/download.gif";

                link.Attributes["onmouseover"] = "MM_swapImage('" + link.ClientID + "','','../images/download_f2.gif',1)";

               link.Attributes["onmouseout"] = "MM_swapImgRestore()";

               link.OnClientClick = "dcsMultiTrack('DCS.dcsuri', '" + link.CommandArgument + "', 'WT.ti', 'ImageButton1');MM_openBrWindow('" + link.CommandArgument + "','PDFs" + i + "','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500')";

                }

             }

}

mlasell
Asp.Net User
Re: programatically add javacsipt link to every PDF on site?1/29/2007 10:00:44 PM

0/0

Uh, nevermind...

It finally entered my dim mind that a Masterpage ContentPlaceHolder is a child of the page.

So the code easily converts in the masterpage cs to

protected

void Main_OnLoad(object sender, EventArgs e)

{

ContentPlaceHolder Main = (ContentPlaceHolder)sender;

for (int i = 0; i < (Main.Controls.Count - 1); i++)

{

ImageButton link = Main.Controls[i]

as ImageButton;

if (link != null)

{

link.ImageUrl =

"/images/download.gif";

link.Attributes[

"onmouseover"] = "MM_swapImage('" + link.ClientID + "','','../images/download_f2.gif',1)";

link.Attributes[

"onmouseout"] = "MM_swapImgRestore()";

link.OnClientClick =

"dcsMultiTrack('DCS.dcsuri', '" + link.CommandArgument + "', 'WT.ti', 'ImageButton1');MM_openBrWindow('" + link.CommandArgument + "','PDFs" + i + "','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500')";

}

}

However, if anyone knows a better way to do this, I am all ears.

Michael

9 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
iNnovative tHinker: Javascript Questions My system freezes when I click a button that is a javacsipt (using IE 5.5) How ... Can I add different multiple tooltips with links on different image maps ...
iNnovative tHinker: May 2008 I need copy from urls inserted on my site using php - sites link will be ...... My system freezes when I click a button that is a javacsipt (using IE 5.5) ...
FAQTs - Knowledge Base - faqts : Computers : Programming ... Can I add different multiple tooltips with links on different image maps ( HotSpots) ...... How can I use a 'for' loop to programatically click a series of ...




Search This Site:










modifying the search module

ttt forum/gallery pack

the same user in multiple portals

web fusion lack of assistance on dnn - can anyone help! please

how do i use an ip:port address in an iframe??

very upset with my hosting provider...

adding help viewable to all users in dotnetnuke 3.0.12

team suite

pass userdata securely using asp.net 2.0

digital certificate

hacker stole my dropdownlist.

deploying web site

self.focus() causing a minor problem

masterpages design time control

please help !!!!!!!!

help:custommembershipprovider

querystring and templates

"copying" dnn? custom modules to help?

child portal - active element

are articles in 2 different languages possible ?

classifieds email error? what is this error?

export item template problems with embedded resources

css menu: treeview/bulleted list

customize rss module? or a custom module?

security using roles and windows authenication

manual account lockout using membershipprovider

dotnetnuke.com is down

flash banner support

where can i find "cbo" and it's method's "initializeobject" etc.

define device filter for a page

 
All Times Are GMT