11-05-2010 10:09 AM
I want to display a multi-line message to users when a button on a form is clicked.
At the moment, I've got something like this:
string sHelpText = "Line 1"; sHelpText = sHelpText + "\n" + "Line 2"; IWebDialogService dialog = form.Services.Get<IWebDialogService>(); dialog.ShowMessage(sHelpText);
where "\n" is (I believe) the C# equivalent of vbCRLF.
But when the message displays, the \n appears to be displayed as a single space character (only). No new line is thrown.
I also tried System.Environment.NewLine - same result.
Any ideas what I need to do to get my lines separated as I want them?
Thanks in advance.
11-05-2010 11:52 AM
Try this - it uses an HTML break:
string sNewLine = "<" + "br" + "/" + ">";
Just insert the string 'sNewLine' anywhere you want a newline in the messge. I use this all the time for jscript alert boxes and exception alerts.
11-06-2010 01:46 AM
Neither of these methods works, I'm afraid.
"\r\n" has the same effect as "\n".
"<" + "br" + "/" + ">" is faithfully rendered as "<" + "br" + "/" + ">" when the message is displayed
11-08-2010 10:17 AM
Looks like the DialogService.ShowMessage is doing some encoding thus overriding your desired behavior. This, and the lack of an 'OK' button on the dialog is why I use JScript alerts instead:
string sNewLine = "\\n";
string sAlert = "alert('This is line 1" + sNewLine + "This is line 2');";
ScriptManager.RegisterStartupScript(Page, GetType(), "Message", sAlert, true);
Note that the original technique I mentioned does work if you're throwing a Validation Exception - which calls the Ext-js alert box rather than the stock alert function.
Keep in mind that you may need to re-work that last line of code if you're calling this from a from snippet. My example is an in-line snippet which is marked as Obsolete in AA.
11-15-2010 06:24 AM - edited 11-15-2010 06:33 AM
Here's what I ended up doing.
1) Create Link controls on the form.
2) Modify the OnLoad event for the form to assign the destination property of the link controls appropriately...
string sNewLine = "\\r\\n";
as the new-line directive within the destination text (sHelpText)..
11-19-2010 02:29 AM
I get the same problem since SP3.
To avoid this problem, I created a custom smartpart with a literal control.
I used a module to load this control on each page.
Now I call my dialog like this:
this.DialogService.SetSpecs(400, 600, "myDialog", "myTitle");