Click here to Skip to main content
15,886,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all
I have a masterpage in my application which has a menu... Menu has a menu element called 'Basket(0)'

I have its content page called Basket.aspx... and ofcourse it will have all schemes selected by user as in e-shoppie...
initially when user log in Menu element should look like 'Basket(0)' but more schemes are added to Basket value should be incremented by 1 like 'Basket(1)' 'Basket(2)' 'Basket(3)''Basket(4)' and so on..

If user goes in basket and delete scheme basket value should be decremented..
I have done this without using Ajax... But if I use ajax its not changing count in Masterpage's Basket count... but I want to change it using Ajax

Here I want to know that is it possible with Ajax? if yes, then how?
I am using repeater on Basket page as well as Scheme page.. Please let me know it question is not clear enough

here is some code

ASP.NET
<asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
<asp:Repeater ID="rptScheme" runat="server">
<ItemTemplate>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
<td align="left" valign="top">
<asp:CheckBox ID="chkEnable" runat="server" CssClass="css-checkbox" Checked="true" AutoPostBack="true" Key='<%# Eval("id") %>' />
<asp:Label ID="lblScheme" AssociatedControlID="chkEnable" Text='<%# ChangeCase(Eval("Scheme_Name"))%>' runat="server" CssClass="css-label"/>
                
                                                                     
                                                                    
 <asp:HiddenField ID="hfScheme" runat="server" Value='<%# ChangeCase(Eval("Scheme_Name"))%>' />
                                                                    
 </td>
<td width="30%" align="right" valign="top" class="remove">
<asp:LinkButton ID="lnkRemove" runat="server" class="basket" CausesValidation="false"
CommandArgument='<%# Eval("id") %>' CommandName="remove">Remove</asp:LinkButton>
 </td>
</ItemTemplate>
</asp:Repeater>
</tr></table>
</ContentTemplate>
    </asp:UpdatePanel>


Thanks..
Posted
Updated 29-Oct-13 22:55pm
v3
Comments
JoCodes 30-Oct-13 3:58am    
Can you post some relevant code which you tried with ajax?
[no name] 30-Oct-13 5:02am    
Have a look... its just a small code.. Menu is in Masterpage with simple names...
JoCodes 30-Oct-13 5:27am    
What you have tried related to access the MenuControl from your content pages inorder to add or remove basket???

1 solution

What I have understood from your Question is You want to add/delete menu items (placed inside the masterpage) through an control event placed in a content page. You can achieve the same through ajax also as you have asked.

Try as below .

Masterpage :

Step 1 : Place the Menu Control inside a separate UpdatePanel .

Step 2 : Add Public method for Adding or Deleting the Menu Items.

Something like
C#
public void AddMenu()
        {
            MenuItem item = new MenuItem("NewOne", "NewOne");
            Menu1.Items.Add(item);//sample shows add but you may need to edit delete etc.
        }

ContentPage

Step 3: Place your repeater inside an update panel ( You have already done it )
Step 4 : Access the Public method

C#
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            ((SiteMaster)this.Page.Master).AddMenu();
//this event has to be replaced accordingly with your linkbutton or checkbox events inside your repeater            
        }


Hope this helps
 
Share this answer
 
v3
Comments
[no name] 31-Oct-13 1:05am    
I am sorry for my bad english... I wanted to say I already have Menu Item called 'Basket(0)' inside the master page (I dont want to add to delete Menu item, I just want Basket(0) item to be renamed accordingly) ... But if I add Item in content page,(remember I have to content pages 1.Portfolio.aspx---where list of schemes is given and add button is given 2. Basket.aspx where added Items are shown along with delete button) '0' inside should be '1' with Ajax.. (without ajax its working)
JoCodes 31-Oct-13 1:18am    
You can modify the AddMenu method which is in the Masterpage accordingly. The key thing is accessing that method for renaming the Basket(0).The step 4 event can be in any content page
[no name] 1-Nov-13 9:04am    
((SiteMaster)this.Page.Master).AddMenu(); I have converted this to vb.net but its not working... vb.net returns DirectCast(Me.Page.Master, SiteMaster).AddMenu() where SiteMaster looks undefined... plz tell me whats that...??
JoCodes 2-Nov-13 3:40am    
Sitemaster is the master page name .It worked for me in C#. I think in VB its slightly different( Dont know VB.net ). May be you can try something like CType(Master, {Your MasterPage Name}).{Your MasterPage.PublicRoutine) ( reference :http://www.velocityreviews.com/forums/t300574-calling-masterpage-subroutines-from-a-contentpage.html )... Please check .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900