Menu item needs to run code during a postback without changing the page url

C

Cal Who

I'm using a web.sitemap with <siteMapNode>'s

contining page addeesses like url="Test.aspx"

and in the master file <asp:Menu>

There are some submenu items that I'd like to simply run a little code
during a postback without changing the url of the page being shown.

That is, from a user's view, she would click a menu item, select an option,
and then (maybe after a flash) continue on the page she's at.

Is that possible?



Thanks
 
A

Andy O'Neill

Cal Who said:
I'm using a web.sitemap with <siteMapNode>'s

contining page addeesses like url="Test.aspx"

and in the master file <asp:Menu>

There are some submenu items that I'd like to simply run a little code
during a postback without changing the url of the page being shown.

That is, from a user's view, she would click a menu item, select an
option, and then (maybe after a flash) continue on the page she's at.

Is that possible?



Thanks

If you don't put a URL in a menu item it'll post back to the current form.
Assuming you have autopostback set anyhow.
You can then have an event for the menu click and see which was clicked, run
some code then do a response redirect
google asp.net menu item postback
 
C

Cal Who

I can't seem to get started. I have:
<siteMapNode title="Preferences" roles="*" description=""/>

and in the master:

<asp:Menu runat="server" autopostback="true"...

I just want to see it post back so I put a break point in

Page_Load on the master and on the active page.

I run debug and hit the break points when the page first loads

But when I click the menu item I do not.

Seems I'm not getting my postbacks.

Comments?



Thanks
 
C

Cal Who

I'm wondering if 4.00 framework adds the postback to the menu capabilities.
I saw the site describing skmMenu which had that feature including a
CommandName on the siteMapNode descriptions.

I also found the following but I'm not sure what that referred to ( don't
have MenuItem elements)
The event is set using menu item server property "OnClientClick":
<oem:MenuItem InnerHtml="<b>Server event 1</b>" ID="menuItem2"
OnClientClick="CallServerEvent('menuItem2')"></oem:MenuItem>

There are quite a few sites looking for info on getting menuitem postbacks
working and because the above are on Microsoft sites I wonder if 4.0 might
have included more capablities.


Thanks
 
A

Andy O'Neill

Cal Who said:
I can't seem to get started. I have:
<siteMapNode title="Preferences" roles="*" description=""/>

and in the master:

<asp:Menu runat="server" autopostback="true"...

I just want to see it post back so I put a break point in

Page_Load on the master and on the active page.

I run debug and hit the break points when the page first loads

But when I click the menu item I do not.

Seems I'm not getting my postbacks.

Comments?

I didn't idly pick that search string out the air.
 
C

Cal Who

I should have mentioned that right now I'm trying to see if
SiteMap.SiteMapResolve event would help.

I tried different things on the siteMapNode url to try to get a postback.
Only a valid url seems to cause a postback.

Thanks
 
A

Andy O'Neill

Cal Who said:
I should have mentioned that right now I'm trying to see if
SiteMap.SiteMapResolve event would help.

I tried different things on the siteMapNode url to try to get a postback.
Only a valid url seems to cause a postback.

Thanks

Autopostback will always call postback.
Top link returned by the search criteria I posted is from someone with the
same problem and describes a solution.
 
C

Cal Who

Andy O'Neill said:
Autopostback will always call postback.
Top link returned by the search criteria I posted is from someone with the
same problem and describes a solution.

I've read it more often than I want to admit.

If you meant adding autopostback="true"...
Note my first reply to you included:
<asp:Menu runat="server" autopostback="true"...
Actually I had tried that before I posted the first time.

If you meant, when he said:
"I re-sequenced my test case and it worked"
I never could figure out what that meant.

If I supposed to add autopostback="true"...
to a sub-menu item. I've no idea how to do that.


Thanks for trying to help
 
C

Cal Who

Cal Who said:
I can't seem to get started. I have:
<siteMapNode title="Preferences" roles="*" description=""/>

and in the master:

<asp:Menu runat="server" autopostback="true"...

I just want to see it post back so I put a break point in

Page_Load on the master and on the active page.

I run debug and hit the break points when the page first loads

But when I click the menu item I do not.

Seems I'm not getting my postbacks.

Comments?



Thanks
I have it working but I believe the control that I have that is datbound
will not do postback without a valid url to go to:
<asp:Menu DataSourceID="SiteMapDataSource1"...

However,I added a second menu using (without a datasource)
<asp:Menu...
<Items>
<asp:MenuItem...
....
</Items>
I do get the postback without specifying a
NavigateUrl
Enabling me to execute code and returning to the same page.

This must be the configuration Andy O'Neill was above referring to.

My only problem now is the two menus insist on being on two lines when I'd
rather they sat next to one another on the same line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top