Hi,
Is it possible that if user click the hyperlink a form will be open?
Thanks.
Is it possible that if user click the hyperlink a form will be open?
Thanks.
14 Answers, 1 is accepted
0
Hi Saif,
Thank you for writing.
Please note that the main purpose of this functionality is to display a hyperlink. Nevertheless you can intercept a link click and execute any code you want. To achieve this you can subscribe to the MouseDown event of the ContentElement and check if the mouse is over a link:
The subscription to the event can be made as follows:
Please let me know if there is something else I can help you with.
Regards,
Dimitar
Telerik
Thank you for writing.
Please note that the main purpose of this functionality is to display a hyperlink. Nevertheless you can intercept a link click and execute any code you want. To achieve this you can subscribe to the MouseDown event of the ContentElement and check if the mouse is over a link:
void
ContentElement_MouseDown(
object
sender, MouseEventArgs e)
{
FieldInfo pi =
this
.radDesktopAlert1.Popup.AlertElement.ContentElement.GetType().GetField(
"textPrimitiveImpl"
, BindingFlags.Instance | BindingFlags.SetProperty |BindingFlags.NonPublic);
TextPrimitiveHtmlImpl text = (TextPrimitiveHtmlImpl)pi.GetValue(
this
.radDesktopAlert1.Popup.AlertElement.ContentElement);
FormattedTextBlock textBlock = text.TextBlock;
FormattedText clickedLink = IsMouseOverBlock(textBlock, e);
if
(clickedLink !=
null
)
{
MessageBox.Show(clickedLink.Text +
" pressed"
);
//here you can execute any code you want
}
}
private
FormattedText IsMouseOverBlock(FormattedTextBlock textBlock, MouseEventArgs e)
{
Point elementAtPoint =
this
.radDesktopAlert1.Popup.AlertElement.ContentElement.PointFromControl(e.Location);
int
linesCount = textBlock.Lines.Count;
for
(
int
i = 0; i < linesCount; ++i)
{
TextLine textLine = textBlock.Lines[i];
int
textLineCount = textLine.List.Count;
for
(
int
j = 0; j < textLineCount; ++j)
{
FormattedText formattedText = textLine.List[j];
if
(!
string
.IsNullOrEmpty(formattedText.Link) && formattedText.DrawingRectangle.Contains(elementAtPoint))
{
return
formattedText;
//found link under mouse
}
}
}
return
null
;
//not found
}
The subscription to the event can be made as follows:
this
.radDesktopAlert1.Popup.AlertElement.ContentElement.MouseDown += ContentElement_MouseDown;
Please let me know if there is something else I can help you with.
Dimitar
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Saif
Top achievements
Rank 2
answered on 02 Jul 2014, 09:10 AM
Hi Dimitar
Thanks a lot on this one.
It really help me a lot.
Thanks a lot on this one.
It really help me a lot.
0
Saif
Top achievements
Rank 2
answered on 02 Nov 2014, 09:47 AM
Hi
I'm having exception error on TextPrimitiveHtmlImpl
pi always null
NullReferenceException was unhandled
I'm having exception error on TextPrimitiveHtmlImpl
FieldInfo pi = this.radDesktopAlert1.Popup.AlertElement.ContentElement.GetType().GetField("textPrimitiveImpl", BindingFlags.Instance | BindingFlags.SetProperty |BindingFlags.NonPublic);
pi always null
TextPrimitiveHtmlImpl text = (TextPrimitiveHtmlImpl)pi.GetValue(this.desktopAlert.Popup.AlertElement.ContentElement);
NullReferenceException was unhandled
0
Saif
Top achievements
Rank 2
answered on 02 Nov 2014, 09:49 AM
Sorry for double post
typographical error on radDesktopAlert1, im using desktioAlert
I'm trying to edit the post to change the control name.
typographical error on radDesktopAlert1, im using desktioAlert
I'm trying to edit the post to change the control name.
0
Hi Saif,
Thank you for writing back.
We have exposed a property for this and now you can access the text block without using a reflection:
I hope this information helps.
Regards,
Dimitar
Telerik
Thank you for writing back.
We have exposed a property for this and now you can access the text block without using a reflection:
void
ContentElement_MouseDown(
object
sender, MouseEventArgs e)
{
FormattedTextBlock textBlock =
this
.radDesktopAlert1.Popup.AlertElement.ContentElement.TextBlock;
FormattedText clickedLink = IsMouseOverBlock(textBlock, e);
if
(clickedLink !=
null
)
{
MessageBox.Show(clickedLink.Text +
" pressed"
);
//here you can execute any code you want
}
}
I hope this information helps.
Regards,
Dimitar
Telerik
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
0
Saif
Top achievements
Rank 2
answered on 03 Feb 2015, 07:23 AM
Hi again.
Can you help me on converting this syntax into VB.Net.
I'm having problem with the adding of the event MouseDown.
Thanks.
Can you help me on converting this syntax into VB.Net.
I'm having problem with the adding of the event MouseDown.
Thanks.
0
Saif
Top achievements
Rank 2
answered on 03 Feb 2015, 07:59 AM
I got it now.
Thanks.
AddHandler
Me
.RadDesktopAlert1.Popup.AlertElement.ContentElement.MouseDown,
AddressOf
ContentElement_MouseDown
Thanks.
0
Hi Saif,
Thank you for writing back.
Indeed I forgot to add the event subscription code. Nevertheless I am glad that you have found the solution yourself.
Do not hesitate to contact us if you have other questions.
Regards,
Dimitar
Telerik
Thank you for writing back.
Indeed I forgot to add the event subscription code. Nevertheless I am glad that you have found the solution yourself.
Do not hesitate to contact us if you have other questions.
Dimitar
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
VLADISLAV
Top achievements
Rank 1
answered on 12 Nov 2015, 09:49 AM
Using this solution and getting exception "An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.WinControls.dll" After click on the link in alert window.
0
Hello Viktor,
Thank you for writing.
You should change the MouseDown event as follows:
I hope this helps.
Regards,
Dimitar
Telerik
Thank you for writing.
You should change the MouseDown event as follows:
void
ContentElement_MouseDown(
object
sender, MouseEventArgs e)
{
FieldInfo pi =
(LightVisualElement).GetField(
"textPrimitiveImpl"
, BindingFlags.Instance | BindingFlags.NonPublic);
TextPrimitiveHtmlImpl text = (TextPrimitiveHtmlImpl)pi.GetValue(
this
.radDesktopAlert1.Popup.AlertElement.ContentElement);
FormattedTextBlock textBlock = text.TextBlock;
FormattedText clickedLink = IsMouseOverBlock(textBlock, e);
if
(clickedLink !=
null
)
{
MessageBox.Show(clickedLink.Text +
" pressed"
);
//here you can execute any code you want
}
}
I hope this helps.
Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
VLADISLAV
Top achievements
Rank 1
answered on 12 Nov 2015, 10:50 AM
Vladislav
0
VLADISLAV
Top achievements
Rank 1
answered on 12 Nov 2015, 10:52 AM
base.Dispose(disposing); here this exception throws still.
0
Hi Vladislav,
Thank you for writing back.
I just tested this and there is no exception on my side. This is why I have attached my test project. Could you please check it and let me know how it differs from your real setup?
I am looking forward to your reply.
Regards,
Dimitar
Telerik
Thank you for writing back.
I just tested this and there is no exception on my side. This is why I have attached my test project. Could you please check it and let me know how it differs from your real setup?
I am looking forward to your reply.
Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
VLADISLAV
Top achievements
Rank 1
answered on 12 Nov 2015, 11:32 AM
Thanks alot , all the problem was in format i thought al i need just link but u also need this thingy "<html><a href=\"#\">link</a></html>" .After adding tags everything warks well.