问题描述
大家好
我的应用程序中有一个母版页面有一个菜单...菜单有一个名为'Basket(0)'的菜单元素
我的内容页面叫做Basket.aspx ...当然,它会让用户在电子购物中选择所有方案...
最初用户登录时菜单元素应该看起来像'篮子(0)',但是更多方案被添加到篮子值应该增加1,如'篮子(1)''篮子(2)''篮子(3)''篮子(4)'等等..
如果用户进入篮子并且删除方案篮子值应该减少..
我没有使用Ajax就完成了这个...但是如果我使用ajax在Masterpage的篮子计数中没有改变数量...但是我想用Ajax改变它
这里我想知道它是否可能用Ajax?如果是,那怎么样?
我在篮子页面以及计划页面上使用转发器..请让我知道它的问题不够清楚
这里是一些代码
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: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..
推荐答案
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
步骤3:将转发器放入更新面板(你已经完成了)
第4步:访问公共方法
ContentPage
Step 3: Place your repeater inside an update panel ( You have already done it )
Step 4 : Access the Public method
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
这篇关于使用内容页面中的ajax更改母版页中的菜单项文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!