帮忙看这个问题.按钮的.

dljinsui 2007-12-21 01:06:57
HTML>>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtValue" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" />
</ContentTemplate>
</asp:UpdatePanel>

*.cs>>
protected void Button2_Click(object sender, EventArgs e)
{
double i;
for (i = 1; i < 1000000000; i++)
{
i += 1;
}
txtValue.text=i.tostring();
}

怎么实现,单击按钮->按钮置灰->后台处理->按钮可用
并且支持AJAX的UpdatePanel,做到无刷新.
...全文
163 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ipqxiang 2007-12-21
  • 打赏
  • 举报
回复
<asp:TextBox ID="txtAddress" runat="server" Width="517px"> </asp:TextBox>
<asp:Button ID="btnUpdate" runat="server" Text="Save" OnClick="btnUpdate_Click" />

把上面2个控件换个位置,要放在UpdatePanel里就有用了
ipqxiang 2007-12-21
  • 打赏
  • 举报
回复
<asp:TextBox ID="txtAddress" runat="server" Width="517px"> </asp:TextBox>
<asp:Button ID="btnUpdate" runat="server" Text="Save" OnClick="btnUpdate_Click" />

把上面2个控件换个位置,要放在UpdatePanel里就有用了
dljinsui 2007-12-21
  • 打赏
  • 举报
回复
11楼,如何再加上下面的代码.
好象不行.
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="update">
<ProgressTemplate>
<div >
<img src="Image/animated_loading.gif" alt="dddd" />
正在存储数据...
</div>
</ProgressTemplate>
</asp:UpdateProgress>

dljinsui 2007-12-21
  • 打赏
  • 举报
回复
感谢11楼,实现.
ipqxiang 2007-12-21
  • 打赏
  • 举报
回复
给你个完速的代码
//页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register
Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit"
TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
<asp:UpdatePanel ID="update" runat="server">
<ContentTemplate>
<asp:Label ID="lblUpdate" Visible="false" runat="server" Style="padding: 5px; font-size: 16px; font-weight: bold;">
</asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnUpdate" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:TextBox ID="txtAddress" runat="server" Width="517px"></asp:TextBox>
<asp:Button ID="btnUpdate" runat="server" Text="Save" OnClick="btnUpdate_Click" />
<ajaxToolkit:UpdatePanelAnimationExtender ID="upae" BehaviorID="animation" runat="server" TargetControlID="update">
<Animations>
<OnUpdating>
<Sequence>
<Parallel duration="0">
<EnableAction AnimationTarget="btnUpdate" Enabled="false" />
</Parallel>
</Sequence>
</OnUpdating>
<OnUpdated>
<Sequence>
<Parallel duration="0">
<EnableAction AnimationTarget="btnUpdate" Enabled="True" />
</Parallel>
</Sequence>
</OnUpdated>
</Animations>
</ajaxToolkit:UpdatePanelAnimationExtender>
</div>
</form>
</body>
</html>

//后台

protected void btnUpdate_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(2000);
this.lblUpdate.Visible = true;
this.lblUpdate.Text = "成功!";
}
LikeCode 2007-12-21
  • 打赏
  • 举报
回复
刚才我尝试为button加个多一个客户端方法,该方法将button设为disabled,但糟糕的是设为disabled后,不会发送AJAX请求,看来scriptmanager是先执行自定义的函数,再执行AJAX代码,...所以一条思路又断了~~~
jc320 2007-12-21
  • 打赏
  • 举报
回复
<ajaxToolkit:UpdatePanelAnimationExtender ID="upae" BehaviorID="animation" runat="server" TargetControlID="update">
<Animations>
<OnUpdating>
<Sequence>
<%-- Store the original height of the panel --%>
<ScriptAction Script="var b = $find('animation'); b._originalHeight = b._element.offsetHeight;" />

<%-- Disable all the controls --%>
<Parallel duration="0">
<EnableAction AnimationTarget="btnUpdate" Enabled="false" /> <EnableAction AnimationTarget="effect_color" Enabled="false" />
<EnableAction AnimationTarget="effect_collapse" Enabled="false" />
<EnableAction AnimationTarget="effect_fade" Enabled="false" />
</Parallel>
<StyleAction Attribute="overflow" Value="hidden" />

<%-- Do each of the selected effects --%>
<Parallel duration=".25" Fps="30">
<Condition ConditionScript="$get('effect_fade').checked">
<FadeOut AnimationTarget="up_container" minimumOpacity=".2" />
</Condition>
<Condition ConditionScript="$get('effect_collapse').checked">
<Resize Height="0" />
</Condition>
<Condition ConditionScript="$get('effect_color').checked">
<Color AnimationTarget="up_container" PropertyKey="backgroundColor"
EndValue="#FF0000" StartValue="#40669A" />
</Condition>
</Parallel>
</Sequence>
</OnUpdating>
<OnUpdated>
<Sequence>
<%-- Do each of the selected effects --%>
<Parallel duration=".25" Fps="30">
<Condition ConditionScript="$get('effect_fade').checked">
<FadeIn AnimationTarget="up_container" minimumOpacity=".2" />
</Condition>
<Condition ConditionScript="$get('effect_collapse').checked">
<%-- Get the stored height --%>
<Resize HeightScript="$find('animation')._originalHeight" />
</Condition>
<Condition ConditionScript="$get('effect_color').checked">
<Color AnimationTarget="up_container" PropertyKey="backgroundColor"
StartValue="#FF0000" EndValue="#40669A" />
</Condition>
</Parallel>

<%-- Enable all the controls --%>
<Parallel duration="0">
<EnableAction AnimationTarget="effect_fade" Enabled="true" />
<EnableAction AnimationTarget="effect_collapse" Enabled="true" />
<EnableAction AnimationTarget="effect_color" Enabled="true" />
<EnableAction AnimationTarget="btnUpdate" Enabled="true" /> </Parallel>
</Sequence>

</OnUpdated>
</Animations>
</ajaxToolkit:UpdatePanelAnimationExtender>
dljinsui 2007-12-21
  • 打赏
  • 举报
回复
不要使用.net提供的button控件,改用picturebox,制作两个图标一个是可用的button一个是不可用的button
程序在执行时显示不可用的图标,执行完后再恢复

--------------------------
能不能给几行代码
ipqxiang 2007-12-21
  • 打赏
  • 举报
回复
用UpdatePanelAnimationExtender
yoursWTR 2007-12-21
  • 打赏
  • 举报
回复
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtValue" runat="server"> </asp:TextBox>

</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>

<asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" />
</ContentTemplate>
</asp:UpdatePanel>

UpdatePanel 不好用
wdtclv 2007-12-21
  • 打赏
  • 举报
回复
不要使用.net提供的button控件,改用picturebox,制作两个图标一个是可用的button一个是不可用的button
程序在执行时显示不可用的图标,执行完后再恢复
dljinsui 2007-12-21
  • 打赏
  • 举报
回复
谢谢三楼,楼上的方法我试过了,不行.
LikeCode 2007-12-21
  • 打赏
  • 举报
回复
用这个updatepanel不知道怎么搞,因为我不知道异步回发返回的处理代码是什么,所以disable button2后不知道什么时候将disable去掉。
其实如果自己手写的AJAX的话,只是个非常菜的问题。

试试这样行不

        protected   void   Button2_Click(object   sender,   EventArgs   e)
{
double i;
Button2.Enable=false;
for (i = 1; i < 1000000000; i++)
{
i += 1;
}
txtValue.text=i.tostring();
Button2.Enable=true;
}
dljinsui 2007-12-21
  • 打赏
  • 举报
回复
Enabled="true"
如果这样行的话,我就不问了,谢谢你的参与
楼下继续.
大正他爹 2007-12-21
  • 打赏
  • 举报
回复
可以动态改变是否可用的。
不可用时 Enabled="true"
灰色可以用样式来处理。

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧