我想要做的是,当我点击消息框“确定”按钮时,它将重新加载整个页面。 这是生成消息框的代码。
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage",
"alert('error!! Try reloading the page! ')", true);
这是重新加载页面的代码。
Response.Redirect(Request.RawUrl);
所以,我想抓住消息框的“确定”按钮生成的事件。并使用它来重新加载页面。
答案 0 :(得分:0)
试试这个。
class DashboardViewController: BaseViewController, CustomTabBarControllerDelegate
{
override func viewDidLoad()
{
super.viewDidLoad()
(self.tabBarController as! CustomTabBarController).customTabBarControllerDelegate = self;
}
override func viewWillAppear(_ animated: Bool)
{
super.viewWillAppear(animated);
(self.tabBarController as! CustomTabBarController).showCenterButton();
}
override func viewWillDisappear(_ animated: Bool)
{
super.viewWillDisappear(animated);
self.hidesBottomBarWhenPushed = false;
(self.tabBarController as! CustomTabBarController).hideCenterButton();
}
override func viewWillLayoutSubviews()
{
super.viewWillLayoutSubviews();
if(!isUISetUpDone)
{
self.view.backgroundColor = UIColor.lightGray
self.title = "DASHBOARD"
self.prepareAndAddViews();
self.isUISetUpDone = true;
}
}
override func didReceiveMemoryWarning()
{
super.didReceiveMemoryWarning()
}
//MARK: CustomTabBarControllerDelegate Methods
func customTabBarControllerDelegate_CenterButtonTapped(tabBarController: CustomTabBarController, button: UIButton, buttonState: Bool)
{
print("isDrive ON : \(buttonState)");
}
//MARK: Internal Methods
func menuButtonTapped()
{
let myFriendsVC = MyFriendsViewController()
myFriendsVC.hidesBottomBarWhenPushed = true;
self.navigationController!.pushViewController(myFriendsVC, animated: true);
}
//MARK: Private Methods
private func prepareAndAddViews()
{
let menuButton = UIButton(frame: CGRect(x: 100, y: 100, width: 100, height: 50))
menuButton.titleLabel?.text = "Push"
menuButton.titleLabel?.textColor = UIColor.white
menuButton.backgroundColor = UIColor.red;
menuButton.addTarget(self, action: #selector(DashboardViewController.menuButtonTapped), for: .touchUpInside)
self.view.addSubview(menuButton);
}
}
或者
这可以选择是否重新加载。
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage",
"alert('error!! Try reloading the page! ');location.reload();", true);
答案 1 :(得分:0)
试试这个:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage",
"alert('error!! Try reloading the page! ');window.location.reload()", true);