Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - Access markup hyperlink Tag property in C#
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Access markup hyperlink Tag property in C#

 Post Reply Post Reply
Author
Message
midzi View Drop Down
Newbie
Newbie


Joined: 02 July 2013
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote midzi Quote  Post ReplyReply Direct Link To This Post Topic: Access markup hyperlink Tag property in C#
    Posted: 02 July 2013 at 9:09am

Hello,

I'm trying to access the Tag property inside the hyperlink click event handler. In VB6 this is easy:

Public Sub MyHyperlink_Click(sender As Object, eventargs As Object)
    MsgBox sender.Tag
End Sub

However, when I want to do this in C# like this:

  public void MyHyperlink_Click(object sender, object e)
{
    MessageBox.Show(sender.Tag);
}

 

it raises the obvious compilation error:

Quote

Error 1 'object' does not contain a definition for 'Tag' and no extension method 'Tag' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

It is not possible to cast the sender to XtremeMarkup.MarkupHyperlink (as shown in the Help) because this class is not present in the ActiveX Controls package, which I happen to own.

Is there any way I can access the Tag property without buying Suite Pro?

Best wishes,

Mariusz

Back to Top
csware View Drop Down
Groupie
Groupie
Avatar

Joined: 08 March 2008
Location: Germany
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote csware Quote  Post ReplyReply Direct Link To This Post Posted: 03 July 2013 at 4:36am
Hi Mariusz,

You can cast the control first like


public void MyHyperlink_Click(object sender, EventArgs e)
{
    Control testTag = sender as Control;
    MessageBox.Show(testTag.Tag.ToString());
}



Hope it works

CS
Product: Xtreme SuitePro (ActiveX) version 17.2.0

Platform: Windows 10 (64 Bit)

Language: Visual Basic 6.0 SP 6a
Back to Top
midzi View Drop Down
Newbie
Newbie


Joined: 02 July 2013
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote midzi Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2013 at 5:31pm

Hi CS,

Thanks, but unfortunately your solution doesn't work. The cast to Control would work with a regular control event handler but apparently markup controls work differently. MarkupHyperlink is a class derived from MarkupObject and does not inherit from Control. That's why the cast fails.

In another post on this forum I found the following example:

public void Hyperlink_Click(XtremeMarkup.MarkupObject Sender, XtremeMarkup.MarkupRoutedEventArgs Args)
{

XtremeMarkup.MarkupHyperlink Element;

Element = (XtremeMarkup.MarkupHyperlink)Sender;

MessageBox.Show("Clicked: " + Element.Tag);

}

This works but is only possible in the Suite Pro edition because the MarkupObject, MarkupRoutedEventArgs, and MarkupHyperlink classes are not included in the Controls package. What I'm trying to do is find a way to access the Tag property without upgrading to Suite Pro. As I found out, it can be done in VB6 (without a cast), so perhaps it is also possible in C#. 

Best wishes,

Mariusz

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.143 seconds.