Print Page | Close Window

Access markup hyperlink Tag property in C#

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=21763
Printed Date: 01 May 2024 at 5:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Access markup hyperlink Tag property in C#
Posted By: midzi
Subject: Access markup hyperlink Tag property in C#
Date 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




Replies:
Posted By: csware
Date 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


Posted By: midzi
Date 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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net