Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Ajax partial rendering and formatemail function problemAjax partial rendering and formatemail function problem
Previous
 
Next
New Post
4/30/2007 8:48 AM
 

Hi,

I'm developing a module that shows a list of contacts and has partial rendering enabled. To display the e-mail i use the DNN API function formatEmail.

When a postback occurs (e.g go the next page), the script generated by formatEmail doesn't render the e-mail link.

Anybody know how to solve this ?

Thx in advance

 

 
New Post
4/30/2007 9:14 AM
 

The formatEmail function generates a javascript link for an email (to obfusticate the email address which is exposed as part of the mailto), so you may have to change it to a plain link as AJAX has issues with client side javascript (note: i haven't had a chance to play with this, so please log it as an enhancement request at support.dotnetnuke.com so we can follow up with it and hopefully update the core to render accordingly)

Cathal


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
11/27/2011 5:14 PM
 

I am always wary about replying to 4 year old posts however since this is the only forum topic I came across when searching for a solution to exactly the same problem building with and running on DNN 4.9 where the issue still occurs (maybe it's fixed in DNN 5 or 6 I don't know) 
... well here goes. 

The DNN FormatEmail generates something like (since I am not copying code probably not going to be 100% accurate here)

<script> document.writeto String.fromCharCode('10','19', ..... etc .... '90'); </script>

Javascript (etc) from the initial post is not recalled when a postback returns when using partial rendering. Neither is directly written scripts returned in the postback response - presumably something to do with the various Script Manager onLoad etc calls not parsing the HTML for scripts.

To make a script run explicitly on a postback you need to invoke the RegisterStartupScript method of the ScriptManager.

DNN 4 AJAX framework doesn't explicitly expose this script manager method but it is very easy to create your own ... along the lines of the following in a global class (see MyAJAX.RegisterStartupScript method in the class at the bottom)

Now we take the FormatEmail response and strip it down to the String.fromCharCode( ....) bit and register a startup script setInnerHTML that puts the String.fromCharCode(...) part into the innerHTML of the (in my case Label) control (see MyAJAX.FixFormedStringCodeScript method in the class at the bottom)

The javascript is quite basic then and I've included it just above the MyAJAX class below

What happens now is that instead of actually writing to the document directly via a script, the ScriptManager inherently dumps a pile of script calls (however many emails on screen) to setInnerHTML in it's own header on the page which are run on every postback so the email is correctly displayed during partial rendering.

Hopefully an fairly elegant solution to the problem - though no doubt someone will tell me otherwise :)

--------------------------- CODE ------------------------------.

function setInnerHTML(sCtlID, sStringCode)
{
    var cCtl = dnn.dom.getById(sCtlID);
    if (cCtl!=null)
    {
        cCtl.innerHTML = sStringCode;
    }
}

Public Class MyAJAX

Private Shared m_Initialized As Boolean = False
Private Shared m_ScriptManagerType As Type

Private Shared Function ScriptManagerType() As Type
If m_ScriptManagerType Is Nothing Then
If Not m_Initialized Then
m_ScriptManagerType = DotNetNuke.Framework.Reflection.CreateType("System.Web.UI.ScriptManager", True)
End If
m_Initialized = True
End If
Return m_ScriptManagerType
End Function

Public Shared Sub RegisterStartupScript(ByVal objPage As Page, ByVal objControl As Control, ByVal sKey As String, ByVal sScript As String)
If Not ScriptManagerType() Is Nothing Then
If Not ScriptManagerControl(objPage) Is Nothing Then
DotNetNuke.Framework.Reflection.InvokeMethod(ScriptManagerType, "RegisterStartupScript", ScriptManagerControl(objPage), New Object() {objPage, objControl.GetType(), sKey, sScript, True})
End If
End If
End Sub

Public Shared Sub FixFormedStringCodeScript(ByVal objPage As Page, ByVal objControl As Control, ByVal sSCScript As String)
Dim nFindSC As Integer = sSCScript.ToLower.IndexOf("string.fromcharcode")
If nFindSC >= 0 Then
Dim sSCPart As String = sSCScript.Substring(nFindSC)
Dim nFindEnd As Integer = sSCPart.IndexOf(")"c)
If nFindEnd >= 0 Then
sSCPart = sSCPart.Substring(0, nFindEnd + 1)
RegisterStartupScript(objPage, objControl, objControl.ClientID, "setInnerHTML('" & objControl.ClientID & "'," & sSCPart & ");")
End If
End If
End Sub



End Class

 
New Post
11/27/2011 5:27 PM
 
What I didn't include in the above post is how to actually use this in your code.

Basically (assuming myText is an ASP label control) instead of

Dim sAddress as String = "someemail@abc.ie"
myText.Text = DotNetNuke.Common.Utilities.HtmlUtils.FormatEmail(sAddress)

We do

Dim sAddress as String = "someemail@abc.ie"
Dim sFormatted as String = DotNetNuke.Common.Utilities.HtmlUtils.FormatEmail(sAddress)
myText.Text = "" 'nothing or some temporary display
MyAJAX..FixFormedStringCodeScript(myText.Page, myText, sFormatted)



 
New Post
3/22/2012 4:32 PM
 
Scott,

Looks like you may have posted the solution I am looking for...however...I think you forgot to post your code for the ScriptManagerControl() method...???

Ben Santiago, MCP Certified & A+ Certified
Programmer Analyst
(SQL, FoxPro, VB, VB.Net, Java, HTML, ASP, JSP, VBS, Cognos ReportNet)
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Ajax partial rendering and formatemail function problemAjax partial rendering and formatemail function problem


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out