Solved

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

Posted on 2008-10-20
3
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
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…

763 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