更新面板触发器

发布于 2024-08-04 00:06:55 字数 443 浏览 1 评论 0原文

在具有多个部分的页面上工作。

最顶部有一个“状态”标签。

下面是用于添加新数据的部分...... 下面是更新数据的部分...... 下面是删除数据的部分... 和... 下面是用于查看数据的部分...(重复者)

此时甚至不真正关心更新和删除部分...只是说明它们在那里,以便显示页面的总体布局。

现在..当我要添加新数据时,提交按钮被设置为更新面板的触发器,该更新面板围绕页面底部的转发器...工作完美...但它并没有从其中删除文本文本框或更新状态标签,因为页面仅部分回发...(显然)

当您单击按钮时,我也希望显示标签(“您添加了数据”)并且文本框被清空。 .. SOOO...我认为我会很棘手,并在状态周围放置一个更新面板,并将其触发器添加和设置到同一个按钮...似乎不起作用:-\我通常不打扰更新面板。 ..但是这个页面有可能有大量的文本数据和格式...

有什么想法吗?

Working on a page with multiple sections.

at the very top there is a "status" label.

beneath that is a section for adding new data...
beneath that is a section for updating data...
beneath that is a section for deleting data...
and...
beneath that is a section for viewing data... (repeater)

not even really concerned about the updating and deleting sections at this point... just stating that they are there so show the general layout of the page.

Now.. when I go to add new data, the submit button is set up as a trigger for an update panel that surrounds the repeater at the bottom of the page... that works perfectly... BUT its not removing the text from the text boxes or updating the status label because the page is only partialy posting back... (obviously)

when you click the button i also want the label to display ("You added data") and the text boxes to be emptied out... SOOO... i thought i'd be tricky and put an update panel around the status and the adding and setting their triggers to the same button... doesnt seem to work :-\ i usually dont bother with update panels... but this page has the potential to have A LOT of text data and formatting...

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤千羽 2024-08-11 00:06:55

想通了。

<asp:updatepanel id="updatepanel1" runat="server">
     <contenttemplate>
          <asp:label id="lblstatus" runat="server /> <br />
     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="btnaddkey" eventname="Click" />
     </triggers>
</asp:updatepanel>

<asp:updatepanel id="updatepanel2" runat="server">
     <contenttemplate>
          <asp:textbox id="tbxkeyname" runat="server />      
          <asp:textbox id="tbxkeytitle" runat="server />      
          <asp:textbox id="tbxkeyvalue" runat="server />      

     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="btnaddkey" eventname="Click" />
     </triggers>
</asp:updatepanel>

<asp:button id="btnaddkey" runat="server" text="submit" OnClick="btnAddKey_Click" />

<asp:updatepanel id="updatepanel3" runat="server">
     <contenttemplate>
          <asp:repeater id="rptkeyview" runat="server">
               ...
          </asp:repeater>         
     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="btnaddkey" eventname="Click" />
     </triggers>
</asp:updatepanel>

以上是页面的基本布局...请记住,每个更新面板之间还有其他内容...(我仍然需要添加编辑和删除功能)
使用 btnaddkey 单击会出现以下代码:

protected void btnAddKey_Click(object sender, EventArgs e)
    {
        Configuration toConfiguration = new Configuration();
        toConfiguration.Title = tbxKeyTitle.Text;
        toConfiguration.Name = tbxKeyName.Text;
        toConfiguration.Value = tbxKeyValue.Text;
        toConfiguration.AddKey();
        lblStatus.Text = "New Key Added.";
        BindKeys();
        tbxKeyName.Text = "";
        tbxKeyTitle.Text = "";
        tbxKeyValue.Text = "";
    }

问题是我需要标签和文本框(每个都在自己的更新面板中)单击一下即可全部更新......

使用上面的代码,它现在正在工作

Figgured it out.

<asp:updatepanel id="updatepanel1" runat="server">
     <contenttemplate>
          <asp:label id="lblstatus" runat="server /> <br />
     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="btnaddkey" eventname="Click" />
     </triggers>
</asp:updatepanel>

<asp:updatepanel id="updatepanel2" runat="server">
     <contenttemplate>
          <asp:textbox id="tbxkeyname" runat="server />      
          <asp:textbox id="tbxkeytitle" runat="server />      
          <asp:textbox id="tbxkeyvalue" runat="server />      

     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="btnaddkey" eventname="Click" />
     </triggers>
</asp:updatepanel>

<asp:button id="btnaddkey" runat="server" text="submit" OnClick="btnAddKey_Click" />

<asp:updatepanel id="updatepanel3" runat="server">
     <contenttemplate>
          <asp:repeater id="rptkeyview" runat="server">
               ...
          </asp:repeater>         
     </contenttemplate>
     <triggers>
          <asp:asyncpostbacktrigger controlid="btnaddkey" eventname="Click" />
     </triggers>
</asp:updatepanel>

Above is the basic layout of the page.... keep in mind that there is other content between each of the update panels... (i still need to add functionality to edit and delete as well)
With the btnaddkey click the following code occurs:

protected void btnAddKey_Click(object sender, EventArgs e)
    {
        Configuration toConfiguration = new Configuration();
        toConfiguration.Title = tbxKeyTitle.Text;
        toConfiguration.Name = tbxKeyName.Text;
        toConfiguration.Value = tbxKeyValue.Text;
        toConfiguration.AddKey();
        lblStatus.Text = "New Key Added.";
        BindKeys();
        tbxKeyName.Text = "";
        tbxKeyTitle.Text = "";
        tbxKeyValue.Text = "";
    }

Problem was that i need the labels and the text boxes (each in their own update panels) to all update on that one click....

using the above code it is working now

§对你不离不弃 2024-08-11 00:06:55

您是说您想要同一页面上有多个更新面板吗?

如果是这样,请参阅

Are you saying you want multiple updatepanels on the same page?

If so see this

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文