The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
unusual Message Box behaviour
Posted: 11 May 10 8:47 AM
|
hi all, just wondering if this is common behaviour or something im doing wrong....
whenever i use more than 1 dialogservice.showmessage... in a block of code it only displays the final message and skips/doesnt diplay the others.
For example, in the code below message1 is never displayed
if (a=b){ DialogService.showMessage("message1") //do something here then: DialogService.showMessage("message2") } |
|
|
|
Re: unusual Message Box behaviour
Posted: 12 May 10 3:37 PM
|
I've seen odd behavior when calling a dialog twice between a page postback. In fact, I've had an open issue with dev since 7.5.2 was released. Apparently, they have addressed it in a hotfix, but I've not had time to verify if all has been fixed.
I would recommend using a JavaScript Alert in your case and a couple of buttons that you can 'click' via the javascript:
string js = "javascript: alert('Starting the process.'); document.getElementById('ctl00_DialogWorkspace_MyDialog_btnAction1').click(); }"; ScriptManager.RegisterStartupScript(Page, GetType(), "Action1", js, true);
btnAction1 Click action: // Do Something here then: string js = "javascript: alert('This process finished'); }"; ScriptManager.RegisterStartupScript(Page, GetType(), "Action2", js, true);
Note that btnAction1 has to be visible in order to render on the page. When I use these, I set the height and width to zero so it is effectively invisible, but the client script can still see it. You can do this in the quickformload if you're using a quickform, or just set the button attributes in the ASCX file if you're using a custom form. Also note that you will have to look at the page source to see exactly what string to pass into getElementById.
|
|
|
|
Re: unusual Message Box behaviour
Posted: 13 May 10 8:36 AM
|
Hi,
Seperate out your DialogShowMessage calls into different methods. When you DialogShowMessage you hand back control to the page so you then lose control server side. Unless the DIalog Show Message has changed drastically in a hotfix I do not see how that could behave any differently?
You could also create a little custom smartpart that looks like a dialogshowmessage, pass the message text as a DialogParameter, and even some instructions as to what to do when they click OK. You can also have Yes/No's etc this way which there is no way to do out of the box (you can do it in VBScript/Javascript but they don't look as good as DialogService ShowMessage's).]
Thanks, Nick |
|
|
|
Re: unusual Message Box behaviour
Posted: 13 May 10 8:42 AM
|
Thanks for your replies all, what you suggested Mike could be a possible solution to another little problem ive got. On my OpportunitySalesProcess.ascx page i have a button. In the OpportunitySalesProcess.ascx.cs script i have the click event code:
protected void Button1_Click(object sender, EventArgs e) { if (DialogService != null) { // DialogActionItem DialogService.SetSpecs(400, 600, "formname", string.Empty ); DialogService.EntityType = typeof(Sage.Entity.Interfaces.IOpportunity); DialogService.ShowDialog(); } }
How do i invoke the click of this button in the OpportunitySalesProcess_ClientScript.js script? Specifically at the end of the executeAction javascript function. |
|
|
|
Re: unusual Message Box behaviour
Posted: 13 May 10 8:51 AM
|
In the OpportunitySalesProcess_ClientScript.js just call the click event of the button in question (whenever you require it to be clicked), so something like:
document.getElementById('BUTTONNAME').click();
should do it, off the top of my head so case might be wrong!
Cheers, Nick. |
|
|
| |
| |
|
Re: unusual Message Box behaviour
Posted: 14 May 10 5:16 AM
|
Hi Andrew,
As far as I am aware you cannot pass variables when you call a click(). You have a couple of options. The code that runs on the server can determine the value of whatever you were trying pass in the firstplace (doing a database query, or reference a field on the screen), or you could have a hidden field on the form that the Button1 click method (the server side method) can reference. Just place your variable (the one you need to be a parameter) in the hidden field before the click() is called, then you can pick it up in your server side Button1 click method.
Thanks,
Nick |
|
|
|
Re: unusual Message Box behaviour
Posted: 14 May 10 5:23 AM
|
Hi Nick,
Thanks again for another great reply. How exactly would that work if what i needed was the StepID of the sales process step the user just clicked?
In the code its populated in SalesProcessGrid_RowDataBound using:
ISalesProcessAudit spAudit = (ISalesProcessAudit)e.Row.DataItem; --- (the stepID being - spAudit.Id.ToString()
The code im going to execute on my Button Click needs this value.
Thanks again. |
|
|
|
Re: unusual Message Box behaviour
Posted: 14 May 10 5:30 AM
|
No problem...I do not know the sales process screen too well so quite difficult to work this one out.
What I would try to do is:
1) add a hidden field to your form, call it something like "ClickedStep";
2) In the javascript code that calls the click() (which I am assuming you attach also in the RowDataBound event) add a line before the click, something like:
document.getElementById('ClickedStep').value = '" + spAudit.Id.ToString() + "'; document.getElementById('BUTTON').click();
The first line will populate the hidden field, whose value you can now reference in you Button1_Click server side method.
Make sense? |
|
|
| |
| |
|