如何调用清晰画面功能 [英] How to call clear screen function

查看:64
本文介绍了如何调用清晰画面功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我想在保存数据后清除所有屏幕,为此我找到了一个代码,但是我不知道如何在按钮save中调用此函数.请咨询

hello,

i want to clear my all screen after save data, for that i find a code but i dont know how can i call this function in my button save.please advice

Public Sub ResetControl(ByVal mypage As Page)
       Dim myForm As Control = mypage.FindControl("Form")
       For Each ctrl As Control In myForm.Controls
           'Clears TextBox
           If TypeOf ctrl Is System.Web.UI.WebControls.TextBox Then
               TryCast(ctrl, TextBox).Text = String.Empty
           End If


           'Clears DropDown Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.DropDownList Then
               TryCast(ctrl, DropDownList).ClearSelection()
           End If


           'Clears ListBox Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.ListBox Then
               TryCast(ctrl, ListBox).ClearSelection()
           End If


           'Clears CheckBox Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.CheckBox Then
               TryCast(ctrl, CheckBox).Checked = False
           End If


           'Clears RadioButton Selection


           If TypeOf ctrl Is System.Web.UI.WebControls.RadioButtonList Then
               TryCast(ctrl, RadioButtonList).ClearSelection()
           End If


           'Clears CheckBox Selection
           If TypeOf ctrl Is System.Web.UI.WebControls.CheckBoxList Then
               TryCast(ctrl, CheckBoxList).ClearSelection()
           End If


           If TypeOf ctrl Is System.Web.UI.WebControls.GridView Then
               TryCast(ctrl, GridView).Columns.Clear()
           End If

       Next




   End Sub




我曾经在按钮单击模式下调用以下代码.但是我遇到了错误.请指教

受保护的Sub btnSaveReq_Click(ByVal发送者作为对象,ByVal e作为System.EventArgs)处理btnSaveReq.Click

ResetControl()

end sub




i used to call the below code in button click mode. but i am getting error. please advice

Protected Sub btnSaveReq_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveReq.Click

ResetControl()

end sub

推荐答案

Protected Sub btnSaveReq_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveReq.Click

' TODO: Add your save code here



ResetControl(Me.Page)

end sub


这篇关于如何调用清晰画面功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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