Solved

How can I fire my (existing) custom control on hyperlink click?

Posted on 2008-10-20
3
290 Views
Last Modified: 2013-11-18
I have developed a custom control (stored locally) that when called from a web page reads a local XML file, interprets the data and returns formatted HTML to be included on the calling web page.  I can hard code a filename in the control call and it all works.  Now I need to include a variable list of more than one filename (as hyperlinks) on the web page.  The user should be able to click a link and the control will be called (again) passing the selected filename and updating the page with the returned HTML.  FYI the returned HTML fills out the middle of a <table> with rows/cols including inline styles, color, fonts, etc.

I'm not sure where to start.  I'm not sure how to repaint the updated HTML without a page refresh.  And since all the processing is done locally (client side - no server), I think  a page refresh would lose the user's selection anyway.  I guess I could use Javascript (or even vbs) to update the DOM with values, but my control returns pretty complicated HTML.  I'd end up writing more js code to interpret the returned HTML and mapping that to the DOM than is reasonable.  If this is the only way I'd probably be better off rewriting my control to return the XML and process it on the page in Javascript to update the DOM.  But honestly I'm not really feel qualified to take that on. I'm hoping there is something I'm missing...

Here is an example that calls my control.
<html>

<body>

<!-- THIS CODE WILL WORK CALLING THE FILE C:\StaticFile1.xml -->

  <table width="100%">	

    <tr>

      <td>Table Heading</td>

    </tr>

    <!-- THE REST OF THE TABLE IS CREATED BY OUR ACTIVE X CONTROL... -->

  

      <script language="vbscript">

        set obj = CreateObject("MyHelper.MyHelper")

        str = obj.ProcessMWTSummary( "C:\StaticFile1.xml")

        document.writeln(str)  

        set obj = nothing

      </script>

  

  </table>

</body>

</html>
 
 

Obviously the vbs would be moved to a sub but this gives an idea what I need to do:

<html>

<body>

<!-- I NEED SOMETHING LIKE THIS THAT WILL UPDATE THE TABLE CONTENTS BASED ON THE USER SELECTION -->
 

  <p><a href="C:\file1.xml">File1</a></p>  <!-- click any of these and the filename is passed -->

  <p><a href="C:\file2.xml">File2</a></p>  <!-- to the vbs, the control is called and the HTML is updated -->

  <p><a href="c:\file3.xml">File3</a></p>
 

  <table width="100%">	

    <tr>

      <td>Table Heading</td>

    </tr>

    <!-- THE REST OF THE TABLE IS CREATED BY OUR ACTIVE X CONTROL... -->

  

      <script language="vbscript">

        set obj = CreateObject("MyHelper.MyHelper")

        str = obj.ProcessMWTSummary( "{CHANGES BASED ON USER SELECTION}")

        document.writeln(str)  

        set obj = nothing

      </script>

  

  </table>

</body>

</html>

Open in new window

0
Comment
Question by:graylint
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22800755
try:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

 "http://www.w3.org/TR/html4/loose.dtd">
 

<html>

<head>

<title></title>

<style type="text/css">

<!--

.file{text-decoration:underline;color:blue;}

-->

</style>

<script language="vbcript" type="text/vbscript">

Sub executeControl(file,o)

	'change the text color so it appears as a "visited link"

	o.style.color="#990099"
 

	Set obj = CreateObject("MyHelper.MyHelper")

	document.getElementById("result").innerHTML = "<table width='100%'><tr><td>Table Heading</td></tr>" & obj.ProcessMWTSummary(file) & "</table>"

	Set obj = nothing

End Sub

</script>

</head>

<body>

<!-- I NEED SOMETHING LIKE THIS THAT WILL UPDATE THE TABLE CONTENTS BASED ON THE USER SELECTION -->

 

  <p><a class="file" onclick='call executeControl("C:\file1.xml",Me)'>File1</a></p>  <!-- click any of these and the filename is passed -->

  <p><a class="file" onclick='call executeControl("C:\file2.xml",Me)'>File2</a></p>  <!-- to the vbs, the control is called and the HTML is updated -->

  <p><a class="file" onclick='call executeControl("c:\file3.xml",Me)'>File3</a></p>

 

	<div id="result"></div>

</body>

</html>

Open in new window

0
 

Author Closing Comment

by:graylint
ID: 31508163
We are busy reworking the control right now so I can't test your suggestion just yet.  But I do understand what you are suggesting and I think it is a good plan.  I didn't want to make you wait for the points on this.  I appreciate your answer.

There will be details to work out, but you gave me a great start.  Hopefully you won't mind if I have a quick question if I run into a jam once I get to test your plan.  I don't expect to since your solution is very clear.

Thanks so much for your help! - Robert
0
 

Author Comment

by:graylint
ID: 22806199
Thanks for your suggestion Hielo!  Your plan looks good and your code is very clear.

Thanks again for your help!
- Robert
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now