按钮点击后我的整个页面刷新 [英] My Whole page refreshed on button click

查看:98
本文介绍了按钮点击后我的整个页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码



i have the following codes

protected void Page_Load(object sender, EventArgs e)
       {
           if (!IsPostBack)
           {
               txtFName.Enabled = false; txtMName.Enabled = false; txtLName.Enabled = false; txtUNic.Enabled = false; txtUDob.Enabled = false;
              
btnSave.Enabled = false; btnDelete.Enabled = false;
           }
       }

       protected void btnAdd_Click(object sender, EventArgs e)
       {
           txtFName.Enabled = true; txtMName.Enabled = true; txtLName.Enabled = true; txtUNic.Enabled = true; txtUDob.Enabled = true;

btnSave.Enabled = true; btnDelete.Enabled = false; btnShow.Enabled = false; btnAdd.Enabled = false;
           //txtFName.Attributes.Remove("readonly");
           txtFName.Focus();


       }





i想让我的保存按钮启用并在点击时禁用所有其他按钮添加按钮,但它似乎只是刷新页面。但是文本框的技巧是有用的。



注意:文本框和按钮位于contentplaceholder中显示的内容页面。



i want to make my save button enable and disable all other when click on add button but it seems that it just refresh the page. but the trick with text boxes is working.

Note: textbox and button are in the contentpage which is displayed in contentplaceholder.

推荐答案


我想你需要学习Asp Page生命周期。



在btnAdd点击事件你写btnSave按钮启用为true,但在页面中没有回发事件你再次btnSave按钮启用为假?为什么?



最后当你打开页面打开btnSave按钮时,你点击btnAdd然后btnSave按钮将被禁用,bcz你禁用页面中的保存按钮不回发活动。





我认为你需要的是,当页面打开时需要禁用保存按钮和文本框,当点击添加按钮需要启用保存按钮和文本框,如果是意味着,在回发事件中你添加保存按钮和文本框禁用代码,而不是回发事件你添加保存按钮和文本框启用代码





并尝试更新面板以获取不刷新页面



https://msdn.microsoft.com/en-us/library/bb399001.aspx [ ^ ]

https://msdn.microsoft.com/en-us/library/bb386454.aspx [ ^ ]



放你的控制内部更新面板,然后只控制更新,我的意思是按钮启用和禁用没有页面引用
Hi I think u need learn Asp Page Life cycle.

In btnAdd click event u write btnSave button enable as true,but in page not post back event u again btnSave button enable as false ? why ?

Finally what u get when page open btnSave button is enabled,when u click btnAdd then btnSave button will disabled,bcz u disable save button in page not post back event.


I think ur need is ,when page open need to disable save button and textbox,when click add button need to enable save button and textbox,if yes means,in postback event u add save button and textbox disable code and in not postback event u add save button and textbox enable code


and try update panel for not refresh page

https://msdn.microsoft.com/en-us/library/bb399001.aspx[^]
https://msdn.microsoft.com/en-us/library/bb386454.aspx[^]

Put ur control inside update panel,then only controls update ,i mean button enable and disable without page refersh


这篇关于按钮点击后我的整个页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆