Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User control postback event -- Arrrggghhhhhh! 1

Status
Not open for further replies.

kubu

Programmer
Jan 10, 2001
23
US

I have a simple horizontal menu in a user control (ascx) form that I use on several aspx pages. The menu has five options (we'll call them A, B, C, D & E). Options A & B are linked to different DIVs on the same aspx page. Options C thru E target different aspx pages.

Here's my quandry: when I start the app, I'm looking at the page that contains the DIV that corresponds to menu item A. When I click on menu item B (same page, different DIV), both the user control ascx and the page it's on are treated as if it's a brand new page load. In other words, when the server-side menu click event fires, IsPostback = False for both the aspx and ascx pages! I'm not targeting a new page, so shouldn't the IsPostback property equal True?

Is there a way to force the IsPostback to equal True, or am I just missing something in regard to handling postback events using a user control?

I'll be very generous with stars for any help I can get on this. :)

kubu
 
What's most likely happening is that you're pointing to something on that page with a traditional link:

location='thisPage.aspx';

or something of the like.

The problem with that is that it isn't a post back. A postback is when a form.submit() is called on a page where the form is pointing to itself.

So, to solve this problem, make each of your menu options that point to divs on that page call some javascript function:

A: javascript:setVal(1);
B: javascript:setVal(2);

and the function should resemble this:

function setVal(val){
document.forms[0].someHiddenVar.value = val;
document.forms[0].submit();
}

So that you'll evaluate the value of someHiddenVar in your page load, and at that point, the .isPostBack property will be true, since it will be a postback in the true sense.

And speaking of sense, I hope that made some. ;-)

paul
penny1.gif
penny1.gif
 
Thanks, Paul. I'll give this a go. My menu is a third party control (Infragistics UltraWebMenu), so I'll have to look at the JavaScript they're throwing behind it to see what's really going on. I have a hunch that you may be correct about the location='thisPage.aspx'; scenario. I know that I have not explicitly set any properties like that in my code, but it's possible that it may be part of Infragistics' code.

A star for you!!!

kubu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top