How to redirect to another View(UserControl '.ascx') in DotnetNuke?

时间秒杀一切 提交于 2019-12-11 04:22:47

问题


I am new in DotnetNuke. I don't know all the terminology of DotnetNuke. Please correct me. That will help me to improve.

I have create a Simple Project with 2 UserControl. 1- View.ascx, 2- ModuleInfo.ascx

1- View.ascx: It contains a button. I want to redirect it to another User Control ModuleInfo.ascx Here is code.

protected void btn1_Click(object sender, EventArgs e)
{
    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL("ModuleInfo"), true);
}

2- ModuleInfo.ascx It contains static table.

How I added Module to DotnetNuke:

1- Add .zip file of build project to Admin --> Extension
2- Edit Module from Host --> Extension --> Edit Module --> Edit Definition --> Add Module Control --> Added key "ModuleInfo" and selected view.
3- Created new page and added module to it. 

When page load, View.aspx is fine. There is a button. But when I click on button, it will redirect to some page but it is blank. It should show the Table.

Can anybody please suggest me if I am missing anything here?


回答1:


NavigateUrl must include tabId and moduleId in the additional arguments in order to work. A simpler method for navigating to views inside your module is simply use the base.EditUrl() which only needs the view's controlKey. See the below code snippet, both lines that set miUrl are equivalent.

protected void btn1_Click(object sender, EventArgs e)
{
    string miUrl = base.EditUrl("ModuleInfo");
    string miUrl = DotNetNuke.Common.Globals.NavigateURL(base.TabId, "ModuleInfo", String.Format("mid={0}", base.ModuleId));

    Response.Redirect(miUrl, true);
}


来源:https://stackoverflow.com/questions/40437658/how-to-redirect-to-another-viewusercontrol-ascx-in-dotnetnuke

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!