dotnetnuke - Accessing page or module level functions from a razor view -


i'm using razor render views in dotnetnuke , working fine except 1 thing i'm missing. i'm trying access module level methods such editurl etc. can't seem figure out how go it.

this have view, although errors on editurl. i'm using razorengine.render render view. there helpers including basic dnn info can't seem find navigateurl or editurl.

any ideas?

@inherits dotnetnuke.web.razor.dotnetnukewebpage<dynamic>  <div id="items-panel">     <table>         <thead>             <tr>                 <th>title</th>             </tr>         </thead>         <tbody>             @foreach (var item in model.items)             {             <tr>                 <td>                    <a href="@editurl("itemid", item.itemid, "viewitem">@item.title</a>                 </td>             </tr>             }         </tbody>     </table> </div> 

i found way seems work editurl creating helper method in razor view shown below. it's shame have because moduleinstancecontext passed constructor of razorengine not exposed view. if else finds way around i'd appreciate comment.

@helper editurl(string keyname, string keyvalue, string controlkey) {     @dotnetnuke.common.globals.navigateurl(dnn.tab.tabid, controlkey, "mid="+dnn.module.moduleid, keyname + "=" + keyvalue) } 

edit: following method worked me. added property model named itemviewurl placeholder token itemid , did replace in view.

in calling page:

dynamic model = new expandoobject(); model.items = itemrepository.list(); model.viewitemurl = editurl("itemid", "[itemid]", "viewitem"); 

and in razor view:

<td><a href="@model.viewitemurl.replace("[itemid]",item.itemid.tostring())">@item.title</a></td> 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -