Anchor Tags in Infopath

R

redbastid

Hi!

I was curious about this: Is it possible to use HTML anchor tags in an
infopath form in order to create navigation hyperlinks that can be used
to jump to different sections within the form?

For example, if I had an anchor like:

<a name="top">

at the top of the form, I could add a hyperlink such as:

<a href="#top">Top</a>

to the bottom so that, when clicked, focus jumps to the top of the
form.

Is there a way to do this in InfoPath? So far, I have not seen a way
to do it. The hyperlink control doesn't seem to give you much
functionality beyond taking you to outside web pages, etc. And, I
haven't found a way of adding the anchor tag, which would be critical
for this endeavor. If you have any insights on this, I would really
like to hear them!

Thanks,
-- Red
 
B

bratt

You can use SelectText to move the cursor to specific field and
you can use a button to fire the movement instead of a hyperlink.
in vb.net:

<InfoPathEventHandler(MatchPath:="GoToTop",
EventType:=InfoPathEventType.OnClick)> _
Public Sub GoToTop_OnClick(ByVal e As DocActionEvent)
thisXDocument.View.SelectText(
thisXDocument.DOM.selectSingleNode("//my:FirstField"), Type.Missing)
End Sub
 
R

redbastid

Hi!

Thanks for the reply! Your suggestion works GREAT for jumping DOWN the
form, but I cannot get it to work for jumping UP the form. If I place
a button inside a child/nested section, I keep getting an error stating
there is an "invalid value" in the View.SelectText call!

It is impractical to put these pseudo-links outside each section so
they are only "on" the top (especially since there are 5 levels deep).

Thanks for any additional help you can provide,
-- Red
 
B

bratt

I have call the SelectText for items up above buttons and it seems to
work fine - jumping in and out of repeating selection when nodes may or
may not be there are were I had problems - you can specify specific
nodes in repeating areas in the xPath of the selectSingleNode call
(I've also used the DataDOMEvent e:
thisXDocument.View.SelectText(e.Parent.parentNode.selectSingleNode(),)
for nodes in the same row) .: can you provide any relevant code ?

Once I was satisfied with my code I placed a try catch block around all
my SelectText calls because I've hit too many scenarios where it
failed and threw an error unexpectedly- and I'd rather have it not move
cursor than throw error to user...
 
R

redbastid

The XML schema I'm working with goes 5 levels deep. In the innermost
section, I added a button, labeled "Top". When I click it, I want to
jump to the root node's first attribute.

Here is the code I currently have for the "Top" button:

IXMLDOMNode node =
thisXDocument.DOM.selectSingleNode("//ns0:RootNodeName/@FirstAttribute");
if(node != null)
{
thisXDocument.View.SelectText(node , Type.Missing); <== blows up
here!
}

The error is:

"The specified values for the View.SelectText call are not valid."

The only thing I can think of is that InfoPath, somehow, is looking for
the root node attribute, @FirstAttribute, within the current segment.

The funny thing is, I have buttons at the top that jump into each
segment--using the exact same code--and all of those work without a
hitch!

How can I make this thing actually jump to the top from within a nested
section?
 
B

bratt

Is that node in the Main data source or from a secondary datasource?
The name space is usually my: for the main datasource. I believe the
selecttext will only work for main datasource plus secondary datasource
is not in the thisXDocument.DOM but in the
thisXDocument.DataObjects("nameobject").DOM

I did have problems on readonly nodes and conditionally hidden nodes -
you can try to use the SelectNodes method (i've yet to use it)?
 
R

redbastid

Hi!

The document was created from a schema, so I do not have a "my" data
source.

That having been said, I opted to use the second field rather than the
first and now it all works like a charm! Go figure!

Thanks for your help!

-- Red
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top