How to decide TabId and ModuleId in Globals.NavigateURL in DotnetNuke? - c#

I am damn confuse in TabId and ModuleId which need to pass as parameters in Globals.NavigateURL.
I have created a project with 2 UserControl. Now I want to navigate in button click event of first UserControl.
I have reviewed some reference. Most of them suggest to pass TabId, Key and ModuleId. I know Key but I don't know what is TabId and ModuleId and how to get it in my .cs file of usercontrol.
Can anybody please suggest me?

If your module is set up correctly, these should be available to you as they are inherited.
From your question it seems you don't know enough about the framework. I recommend that you get a copy of the DNN 7 book. It's relevant to DNN 8, and should start you off correctly. There are other things available: the wiki and the developer resources there.

In answering your other question, I told you that the following two lines of code are equivalent:
string miUrl = base.EditUrl("ModuleInfo");
string miUrl = DotNetNuke.Common.Globals.NavigateURL(base.TabId, "ModuleInfo", String.Format("mid={0}", base.ModuleId));
If you inherit from PortalModuleBase, you have access to TabId and ModuleId in the base class. If you only need to navigate to a module control (view) in the same module, base.EditUrl() works fine. You need to use NavigateUrl() if you need to navigate to another module or to another page (tab).

Related

Sitecore Custom Rules

I have a custom rule in Sitecore:
where person's status is [condition,Tree,root=/sitecore/content/Home/PersonStates, specified state]
I want to replace the hard coded path with one that points to any folder that has it's template id matching the one I specified. This is because the author will create these values (of a specific template in the root folder).
I have tried this and it does not work:
where person's status is [condition,Tree,root=query:/sitecore/content/Common/Categories/*[##templateid='{3B0461BF-9ABC-4AF1-B937-C8D225FC2313}'], specified state]
Furthermore, I need to restrict some of these values based on properties that these items would have.
Eg: The author adds 5 states. I need only those states which have the active flag set to true.
How would I do this?
Out of the box the Tree Macro does not support this, the solution is to create a custom Macro that allows a query to be executed. In order to do this you will have to implement IRuleMacro and implement your logic. Make sure to URL encode your query. Also note that the macro does not have any context when called, so you will have to implement this yourself. An example of this can be found here

Using Form to dynamically generate buttons/panels for a Rule Engine

I'm writing my own Rule Engine, I've looked at a couple that existed but I'm looking for something else which I couldn't find examples to.
I'm looking for a similar application where I can dig into and learn how to do it.
Now, my question is REGARDLESS of the Rule Engine, more of a Form/Dynamic question, but if with your answer you can
relate to what I eventually want to do, that would be great.
Regarding the UI, I'm using Visual Form and the I'd like it to be like this:
http://i.imgur.com/5istREF.jpg
Now, once the user select on the final check box "And/Or" I want him to be able to enter another rule, exactly the same format as the first one.
http://i.imgur.com/N588sjj.jpg
Now the user can basically do it as many times as he wants, so I'm looking for a way to dynamically handle it and create buttons/pannels or even using the same ones (but every time he can enter different values).
Like I've said if you know any similar application/code that I can look into, regardless of rule engine, that will help as well.
Eventually I will take all the fields that he entered and turn it into code.
If I understand you correctly, what you can do is make a controller of your own which is defined in an additional form and then you can add it to your main form as much as you want.
You can define this new controller (meaning a new form) to hold only a single line of the comboBox and then add it to a location in your main form which is based on the location of the previous controller.
Here is an example which adds several control of a class called CNewControl to a tab called newControlsTab one after the other.
int controlHeight = 0;
foreach (CNewControl newControl in newControlList)
{
this.newControlsTab.Controls.Add(newControl );
newControl.Dock = DockStyle.Top;
newControl.Location = new System.Drawing.Point(40, 3 + controlHeight);
controlHeight += newControl .Size.Height;
}
You can of course change it to add your line only once when the user chooses the appropriate option in which a line should be added.

Validating user role's page level access

My question is almost similar to this
ASP.Net Roles: Page-Level Security Question
except for the fact that I'm not using asp.net membership, What I have done is I have created roles and assigned pages to roles, menus are also populating according to the user's role. I want to restrict user to access pages by simply typing the PageName.aspx , One solution might be checking on every page load, but I don't think it's efficient. I have googled but only found solutions for adding <location path="Logon.aspx"> to restrict, I have to add this for every page in web.config, which defeats the whole purpose of keeping this thing dynamic, I am using Form Authentication, Some are suggesting creating a Base Class and derive other pages from that class, I think there may be some global.asax way to acheive this, but have no idea. Please suggest me best approach to achieve this !
P.S : I am not using ASP.NET Membership
legendinmaking,
This is depend on your project layout . One solution is that you create a folder structure where you place webconfig and there you give permission for the user i think this may be one solution and may be others.
finally, what I did is I checked access of Pages for every user on MasterPage's Page_Load using a method name IsPageAssignedToRole() to check
string requestedPage = Request.Url.Segments[Request.Url.Segments.Length-1];
if (requestedPage != "UnAuthorized.aspx")
{
AdminUserAuthInfo au = (AdminUserAuthInfo)Context.Items["AdminUserAuthInfo"];
int current_role= int.Parse(au.Roles[0].ToString());
if (!AdminRole.IsPageAssignedToRole(current_role, requestedPage))
{ Response.Redirect("UnAuthorized.aspx",true); }
}

Creating Dynamic Menus - calling extern Function

I got a requirement to create a dynamic menus using extern function so, we can consume it anywhere, following is the complete requirement :
Please create a dynamic horizontal link menu in the top of the Master Page. This will be the menu that is displayed on every page. We need to be able to set the links on this page from the code behind. The information we want to set is the link text, and the link path (href). The idea behind this is that based on who is logged into the application, and what page they are on, there will be different link possibilities. We should make this code reusable. The procedure to actually lay out the links would look something like this:
public static extern void SetDynamicLinks(Control ContainingControl, string[] arLinkTitles, string[] arLinks) { …code… }
We would call a procedure from the Page_Load of the Master Page that would decide what links we need to display. This procedure would be application dependant. This procedure would then call the "SetDynamicLinks" procedure mentioned above passing it the required parameters to make the correct links in the passed container control.
Any help for above, will be most appreciated. Thanks in advance.
The question does not make sense, if that is what you have been asked to do, then you would assume that either:
that there is already a SetDynamicLinks method developed by somebody else and lives in an unmanaged external dll, hence you would use extern to call that..
or, they are asking you to create that unmanaged dll in say C++, that will contain the SetDynamicLinks method and then can be called by other people using extern..

(.net) Kind of design question

My typical application has a couple of textboxes, checkbuttons, radiobuttons, and so. I always want to load the settings the user used the last time when the program starts, and also want to save the settings as the users clicks "Save settings" or closes the application. When the user attempts to save the settings, I'll have to check each of the controls for input errors (sometimes they have to have a max length, other times only caps, other times other things, there isn't a rule for them all, everytime it'll be different), and only if everything's OK i'll let him save the options. If there is something wrong, no option is saved and my errorcontrol provider will pop up a description of the input type info that should be put in that control.
I've been designing this from scratch for all my projects, but it's being a pain to do it. So I'd thought maybe now was the time to do some library to help me. I thought initially that maybe it'd be a good idea to have all the controls on my form that are going to be part of this save/load process to have an attribute associated with them, something like this
public delegate bool InputIsOkHandler();
public class OptionsAttribute : Attribute {
public Control controlRef;
public InputIsOkHandler IsInputOk;
public string errorMessageToShowOnErrorProvider;
public OptionsAttribute(Control controlRef, InputIsOkHandler inputHandler, string errMessage) {
...
}
}
The main problem here is that when I declare the attribute on a given var:
[Options(...)]
TextBox textBox1 = new TextBox();
I'll get
Error 1 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.
So I guess this approach isn't the best one. What would you guys do in this situation? Would you use attributes? Would you use other mechanisms?
Thanks
Do you know that .NET already includes such a system since 2.0? See MSDN, CodeProject and this white paper from WestWind.
The Personalization and User Profiles supported in ASP.NET 2.0 can be a nice way to achieve your goal.
You can check this MSDN article for a overview Personalization in ASP.NET 2.0

Categories

Resources