Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, May 18, 2024 
 
slxdeveloper.com Community Forums  
   
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!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Custom dialog smartpart issue - Page.IsPostBack always true?
Alec Denholm
Posts: 34
 
Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 09 10:31 AM
Hi,

I've got a custom smartpart (an .ascx file written in VS2k8) which successfully launches into the dialog workspace, from a toolbar button on the Opportunity main view. The smartpart has asp buttons on it, which cause a postback event when clicked; this is undesirable, but as I couldn't find a way to stop them doing a postback, I designed a workaround using a branch in the page's Page_Load event, which looks to see if Page.IsPostBack is true; which I assumed was only the case following a user interaction with one of the form controls.
However, my assumption was incorrect, and this leaves me with a problem:

Firstly, the Page_Load event fires every time you navigate from one Opportunity record to the next, even if you don't press the toolbar button to instantiate the dialog. Is this supposed to happen? It would be good if this can be avoided as the Page_Load event includes database calls and processing which would slow down simple Opportunity navigation.
Secondly, and more game-breaking, is this issue: after debugging the Page_Load event, I see that Page.IsPostBack is ~always~ true, whether caused by Opportunity navigation or controls on the form, submitting or cancelling the dialog; the only time Page.IsPostBack is ever false is the Very First Time the client builds the Opportunity Detail view. Any time after that it's as if the form is never unloaded.

I've tried several workarounds for this, like hidden form controls to state what event fired the Page_Load and therefore what to do, but it's getting seriously complex and inefficient.

What am I doing wrong? It seems I've made a fundamental wrong assumption, but I don't know what it is... why is Page.IsPostBack always true?! How can I unload/reset my form, or better yet, not have it load at all until I click the toolbar button?

Thanks By the way SLxDev.com has been invaluable thus far in this development.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Aug 09 12:56 PM
Yeah, don't use Form_Load. Instead have your SmartPart inherit from EntityBoundSmartPartInfoProvider and then override OnFormBound and put your load code in there instead. You'll see the other OOTB deployed SmartParts are also constructed this way for examples.
[Reply][Quote]
Alec Denholm
Posts: 34
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Aug 09 11:51 AM
Thanks Ryan. Would I be right in assuming OnFormBound is comparable to LAN's AXFormChange? So firing at the point at which the form receives/changes it's bound entity/ID? (Rather than form load).

This would essentially cure all my problems as I guess my load code wouldn't be triggered by buttons on the dialog form either. Awesome Thanks again.
[Reply][Quote]
Alec Denholm
Posts: 34
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 4:47 AM
Actually, that's not worked at all. 'OnFormBound' fires every time I click a button on the dialog, just as 'Form_Load' did.

So perhaps the issue is that asp:Buttons always cause these two event to fire? Perhaps I should explain what I'm trying to achieve.
Imagine a form with 4 buttons on it. Pressing a buttons turn it a different colour, to indicate it's been 'selected'. This row of buttons essentially emulates the behaviour of a radio button group, that is to say 'selecting' (pressing) one of the buttons in the row 'deselects' (de-colours) the other buttons in the row. The button selection is determined by a data value (e.g. 1, 2, 3, or 4), which is loaded when the form is opened and saved when the form is closed.

The problem I'm having is that when you click on one of the buttons, the code to colour that button and de-colour the other 3 is run fine, but then the load code (in 'OnFormBound', previously in 'Form_Load') is run, which reverts the button selection to the saved value. I need that load code to only run when the form is first opened, and not be triggered by the buttons on the form itself, which are only intended to be changing colour when clicked.

I know one way around this would be to have the buttons on the form do a Save before the load code is run again, thus it'd load the new data and display the selected buttons correctly. The problem with this is that I didn't want to save data until the user clicks the Save button to submit the form, or the Cancel button to exit without changes.

So I need a way to run the button colour changing code without it triggering the load code. My only other option would be to save changes on the fly, then revert them if the user clicks Cancel. Ideas?
[Reply][Quote]
slxguy
Posts: 71
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 8:16 AM
OnFormBound will always run after Form_Load runs (which will occur every time someone clicks a button because a regular ASP button will cause a postback).

Do you have to use these colored buttons? Will radio buttons work for you? If not then you will need to store values into the session as it is the only way I can think of to achieve what you are looking for. (unless you use AJAX)
[Reply][Quote]
Alec Denholm
Posts: 34
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 11:13 AM
Unfortunately 'they' are quite insistant on it being buttons. I could give sessions a go, I've not used them for a long time so I'll need to research a bit first I assume they work in SLx web..?
Other than that I've been experimenting with using Java instead which does seem faster in terms of not posting back every time you click a button. The issue I'm struggling with at the moment is trying to load captions on to them... I don't know how to reference an HTML button (and update it's properties) in the C# code.

Thanks for the suggestions thusfar.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 11:37 AM
2 ways to do this:

Client side:
Have the color be set using javascript and store the state on a hidden (server side) field so that it is available for server side processing. (Not sure about all your requirements, but this works for me most of the times).

Server Side:
On the Event Handlers for the Button, store the choices on the Session state.
On the Load code after the data is loaded (if necessary, you may use variables to avoid reloading data that is already present, such as "IsLoaded") read your Session state for the buttons and process the coloring accordingly.

In other words, move the coloring code from the Event handler of the buttons to the FormBound event of the Form.
[Reply][Quote]
slxguy
Posts: 71
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 12:58 PM
Quote:
Originally posted by Alec Denholm

Unfortunately 'they' are quite insistant on it being buttons. I could give sessions a go, I've not used them for a long time so I'll need to research a bit first I assume they work in SLx web..?
Other than that I've been experimenting with using Java instead which does seem faster in terms of not posting back every time you click a button. The issue I'm struggling with at the moment is trying to load captions on to them... I don't know how to reference an HTML button (and update it's properties) in the C# code.

Thanks for the suggestions thusfar.


The Session is something inherent to every web page. Let's say I want to store a username and a id to the session.

Session.Add("CustomUsername", = strUsername); //Where CustomUsername is used to reference the object later and strUsername is the var with the username in it
Session.Add("CustomerID", intCustomerID);

Now to get these values later You just read Session["CustomUsername"] (don't forget to cast these to their correct types). Hopefully that is the correct c# syntax, I'm used to VB.
[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Aug 09 1:27 PM
Following along this path, you would do something as follows:

On the Event Handlers of each button:
Button1_Click(object sender, EventArgs e)
{
Session.Add("SelectedButton", "Button1");
}

Button2_Click(object sender, EventArgs e)
{
Session.Add("SelectedButton", "Button2");
}


And, on the FormBound event, and the end of it (after all loading code has run), you would then:

string selectedButton = Session["SelectedButton"];
if (!String.IsNullOrEmpty(selectedButton))
{
swtich(selectedButton)
{
case "Button1":
//Add your code here for Button 1
break;
case "Button2":
//Add your code here for Button 2
break;
......
}
}
[Reply][Quote]
Alec Denholm
Posts: 34
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Aug 09 3:51 AM
I'm going to go with client-side java for changing the buttons colours, simply because it's quicker not to call back to the server on every selection, and - well in my example I said there were 4 buttons, there's actually 4 per row, and 16 rows... so I think 16 or more postbacks (and the associated dimming of the dialog) no matter how fast would be annoying to a user.
[Reply][Quote]
MK
Posts: 8
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 11 3:08 AM
fiogf49gjkf0d

Hi,


I have a similer issue where I ahve some code written in OnFormBound() where I am checking for Page.IsPostBack to do some work only when the form is loaded. But Page.IsPostBack is always true.


Any idea ? suggestions ?


 


Regards

[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Sep 11 7:53 AM
fiogf49gjkf0d

What are you trying to achieve?


Keep in mind that a SmartPart is a portion of the Page, so the IsPostBack flag is not applicable (also, keep in AJAX calls into context).


That being said, any suggestions would have to be based on what you are trying to achieve.

[Reply][Quote]
johnsonjeven
Posts: 1
 
Re: Custom dialog smartpart issue - Page.IsPostBack always true?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Sep 15 1:50 AM

IsPostBack is a property of the Asp.Net page that tells whether or not the page is on its initial load or if a user has perform a button on your web page that has caused the page to post back to itself. More about.....Asp.Net Ispostback


Johnson

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 5/18/2024 6:25:10 PM