Another issue I have in DNN5:
I'm currently creating a module that shows a GridView that has a "Edit" column.
When user clicks on "Edit" column, it should open an edit form in a new window.
This edit form is an ASPX-page inside my module folder and it expects a ModuleId parameter in order to access the module Settings; that part works fine and I'm able to retrieve the Module settings.
However, I still have the following issues:
How can I localize my Labels? I have tried DNN's label control, but no success. I also tried asp:Label with "meta:resourceKey", but it looks like it isn't able to access the local resource file.
It's very annoying to use Aspx-pages in my module since it will operate outside DotNetNuke's context. Does anybody knows an approach that allows me to use PortalModuleBase?
I have tought about displaying a DotNetNuke page in the new window, just by referencing the Control to load. However when I do that, it will show me the full page (so with navigation bar, footer, and so on) and I actually just want to show the control.
Besides, I'm only able to open my Aspx-page by referencing to /DesktopModules/MyModule/Page.aspx instead of DNN's NavigateUrl or so.
Thanks for your replies.
DNN will hide all other modules on the page whenever a control (or ctl=mycontrol) is specified for the page. So,
You should change your code from an ASPX page to an ASCX control.
Add the ascx control to the Module Controls section of your module's Module Definition.
Use DNN's NavigateURL function to generate the link. You'll want to use one of the options where you specify the Control Key (i.e. NavigateURL("edit", "SkinSrc=[G]" + Globals.QueryStringEncode( DotNetNuke.UI.Skins.SkinInfo.RootSkin + "/" + Globals.glbHostSkinFolder + "/" + "No Skin" ))
In the above sample, "edit" is the control key you specified for the control.
Why not load the edit interface in another ASCX file rather than an ASPX page? Check out http://dnnsimplearticle.codeplex.com for some examples in C#. It's a basic article module, but does a lot of useful things from a DNN perspective.
Mate for localization Aspx-pages operating outside DotNetNuke's context i suggest you to do it programatically. It will give you more control and you can debug it if some problem arises.
Like EfficionDave suggest use Control Key (i.e. NavigateURL("edit", "SkinSrc=[G]" + Globals.QueryStringEncode( DotNetNuke.UI.Skins.SkinInfo.RootSkin + "/" + Globals.glbHostSkinFolder + "/" + "No Skin" )) method
/Adnan Zameer
http://www.adnanzameer.com
Related
To explain confusing title, here is the deal. I have user control which has Like button in it, and I load this User control dynamically multiple times on my homepage. When loading it dynamically I set src of like button iframe dynamically too, here is the method:
public void SetLikeButton(int ID)
{
facebookIframe.Attributes["src"] = "//www.facebook.com/plugins/like.php?href=" + HttpUtility.UrlEncode("http://www.sample.com/subpage/" + ID.ToString()) +
"&send=false&layout=box_count&width=50&show_faces=false&action=like&colorscheme=light&font&height=90";
}
But when I press any of Like buttons, only domain name is gets "liked" on user profile. I need it to share full path,rather than just domain name.Is that possible?
Can't help on the iframe version but this is based on the HTML5 version at
https://developers.facebook.com/docs/reference/plugins/like/
Div Tag for the markup
<div id="fbdiv" class="fb-like" data-href="" data-send="true" data-width="450" data-show-faces="true" runat="server"></div>
In pageload of control
fbdiv.Attributes["data-href"] = "http://www.yoursite.com";
If the control gets loaded multiple times add a parameter to change the URL
I have created a web page that I use as a small dashboard to hold issue or no issue. It works great. The page uses an .aspx and .aspx.cs. I would like to be able to reuse the information on this page on other pages. My site already uses master pages and I have not been able to find an easy way to include this information.
How can I use an include from a page that has coding in the code behind easily?
Typically you use Web User Controls for this.
Web User Controls allow you to package up other controls into one that you can drop onto multiple pages. They are great for common UI items such as address entries, dashboards, etc. Basically anything that needs to be the same across multiple pages.
At the risk of seeming very obvious - do you mean usercontrols. These will allow you to reuse chunks of functionality across your site.
I guess this question falls into two categories: User Controls, and Code Reuse. Not sure which one you are after.
User Controls
If you are talking about the controls on your page you will want to create a common user control.
Code Reuse
You need to create a common class (whether it is static or not depends on how you intend to use it) and define functions within that class.
For instance, lets say you have a page that you want to print "Hello World!" on any aspx/.cs page.
You could do this
public static class MyClass
{
public string PrintHelloWorld()
{
return "Hello World!";
}
}
Then you call it from any of your pages like so:
MyClass.PrintHelloWorld();
Right click on the project > Add New Item...
Select User Control (.ascx)
Put your markup & code behind there.
Then you add that control in any other page (includding other controls [although I wouldn't recommend that])
It sounds like you may want to create an ascx User Control.
http://msdn.microsoft.com/en-us/library/ie/2x6sx01c.aspx
I have a content page which has a related master page.
I register a prefix <%# TagPrefix ..... and can load other custom controls at that namespace.
However, one particualar control at the same namespace, when added to the aspx page, breaks it.
The control in question inherits from asp:Panel, has a parameterless constructor, defines a few public accessors, and creates some standard child controls, and nothing much else.
Are there some fundamental restrictions to creating custom asp controls that I am breaking unknowingly?
Add the control back to the page. Delete the designer file for the page: .aspx.designer.cs
Then right click on the page and select Convert to Web Application. This should give you the actual error the page has when attempting to write the control definition to your designer file.
I suspect there is a compilation error in your custom control.
My control was attempting to access Page.Header which was null as the master page had not marked the tag with runat="server".
I guess that is a fundamental restriction that I was looking for...
This might be a ridiculously easy question, but it has me stumped. I have a web form where I'm trying to create a hyperlink in the code behind to a file server share, e.g. file://myServer/Shared/, but when the page is rendered, the link doesn't include the server name, i.e. file:///Shared/. I don't know why this happens. Any help or insight is appreciated.
UPDATE:
Sure, here is the snippet where the link is being set.
//The link is embedded in a table
HyperLink link = (HyperLink)e.Row.Cells[1].Controls[0];
link.NavigateUrl = #"file://myServer/Shared/";
As a test, I assigned the link to a string value and the link prints the expected url.
string foo = link.NavigateUrl;
//Displays this
"file://myServer/Shared/"
I don't know why this doesn't appear when the link is rendered in the final page.
UPDATE 2:
Ok, so I know I have to set the absolute path in the code-behind, I thought that's what I was doing, but it still won't render correctly.
UPDATE 3:
I followed pjacobs suggestion about setting the test property and it was actually a step in the right direction. I have the following:
link.Text = "link text";
Now the link gets rendered as follows: file:///myServer/Shared. I'm almost there except it gives the extra '/' in front of the server name. I'll keep playing with it, this seems like it should be so simple, I don't understand why ASP.Net renders the URL differently.
You have to set the Text property of the HyperLink... link.Text = "whatever"
Are the resources inside the project? If so:
you need to use ResolveUrl to resolve the "web location" of the resource.
http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx
if you're using an asp.net control you shouldn't need to use the resolve url, but you need to refer to the location of the file relative to the path of the project.
If not:
Did you give the proper read account to ASP.NET process?
Use a virtual directory?
http://www.dotnetspider.com/tutorials/AspNet-Tutorial-86.aspx
I'm trying to use ResolveUrl() to set some paths in the code behind of a custom ASP.NET user control. The user control contains a navigation menu. I'm loading it on a page that's loading a master page.
When I call ResolveUrl("~") in my user control it returns "~" instead of the root of the site. When I call it in a page I get the root path as expected. I've stepped through with the debugger and confirmed, ResolveUrl("~") returns "~" in my user control code behind.
Is there some other way I should be calling the function in my user control code behind to get the root path of the site?
look at System.Web.VirtualPathUtility.ToAbsolute.
wonde's comment above led me to the answer --
I was attempting to use ResolveUrl before the control's page load fired. Therefore there was no context page for the function yet.
I moved my code into the page load function and now it's resolving as expected.
Thanks for the nudge in the right direction.
Take a look at this MSDN example. http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveurl.aspx. and Rick Strahl's Web Log http://www.west-wind.com/Weblog/posts/154812.aspx
I suppose if it works on the page but not the control i guess you could try
this.Page.ResolveUrl("~");