Use inline code in layout.master

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/29/2009 8:28:05 AM
Gravatar
Total Posts 30

Use inline code in layout.master

Can I use inline code in the file layout.master?

I only need to say:

if a variable = true then

show an image

end if

(I want to put this code in asp:Panel tags)

thanks

1/29/2009 8:30:18 AM
Gravatar
Total Posts 18439

Re: Use inline code in layout.master

Just create a UserControl with inline code and then include the UserControl in layout.master, you cannot do it directly in layout.master because it has a code behind file.

Hope it helps,

Joe

 

1/29/2009 8:44:41 AM
Gravatar
Total Posts 30

Re: Use inline code in layout.master

In which folder are there UserControl already existing I can see how are made?

1/29/2009 9:24:40 AM
Gravatar
Total Posts 18439

Re: Use inline code in layout.master

There are no inline UserControls included in mojoPortal, but you can use the hello world example to get started.

Then you register the control in your layout.master file.

http://msdn.microsoft.com/en-us/library/fb3w5b53.aspx

http://msdn.microsoft.com/en-us/library/sbz9etab.aspx

Hope it helps,

Joe

 

1/29/2009 9:35:38 AM
Gravatar
Total Posts 30

Re: Use inline code in layout.master

Can I create a UserControls even if I didn't use mojoPortal source code to install it?

1/29/2009 9:42:15 AM
Gravatar
Total Posts 18439

Re: Use inline code in layout.master

Yes, with an inline code user control, you can just drop it in and it works. With codebehind version you have to compile it into a dll which goes into the /bin folder.

Hope it helps,

Joe

1/29/2009 9:57:05 AM
Gravatar
Total Posts 30

Re: Use inline code in layout.master

Ok I'm trying it...I will you know

1/30/2009 3:13:39 AM
Gravatar
Total Posts 30

Re: Use inline code in layout.master

Hi Joe,
Sorry but I'm not so good with UserControl!!

I tryied this:

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{
this.Response.Write("<img src='Data/Sites/1/skins/Myfolder/img/Carto.jpg' width='245' height='62' />");
}

</script>

and it runs, but If I do this

<script runat="server">

private void Page_Load(object sender, System.EventArgs e)
{
if WebUser.IsInRoles("Admins;Cartography administrators;")
{
this.Response.Write("<img src='Data/Sites/1/skins/Myfolder/img/Carto.jpg' width='245' height='62' />");
}
}

</script>

I have an error:
We're sorry but a server error has occurred while trying to process your request.
...
...


 

1/30/2009 12:42:35 PM
Gravatar
Total Posts 18439

Re: Use inline code in layout.master

In ASP.NET using Response.Write is almost always the wrong thing to do. Get the Classic ASP out of your mind.

Just put an <asp:Image or event a plain <img id="imgToShow" runat="server"

Then just hide it like this if the user is not in the role:

imgToShow.Visible = false;

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.