Sending a form which is outside of the mojo CMS

A place for discussion about skinning and design. Before posting questions here you should review the documentation about creating skins.

This thread is closed to new posts. You must sign in to post in the forums.
11/25/2009 1:06:47 PM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Sending a form which is outside of the mojo CMS

Hi guys, hope you're all good.

The first site I'm working on with mojo is very nearly done, the only thing I have to do is link up a form...

The site is on a test domain here: http://www.russellrichardson.hostinguk.org

See the form on the left? That's been created in the layout.master page. Now, I want to process that form somehow and send off to an email...

Should i:

  1. Use CGI
  2. Use an external .NET script (VB, as that's what I write), and if so how would I go about doing that (i'm not a developer as such!) and including it in the layout.master page (could I in fact add a <script></script> section at the top of the page to handle this and try my hand at C#?
  3. Use something else like JavaScript

If I was building a standard site using .NET i'd just create an onclick event for my button in teh VB codebehind and process it using the SMTP mailer class...

As ever, help is appreciated.

Thanks

11/25/2009 2:13:04 PM
Gravatar
Total Posts 18439

Re: Sending a form which is outside of the mojo CMS

Encapsulate your form inside a VB.NET UserControl, then put the user control in your layout.master Then do the button click as you normally would and after completing the postback logic do Response.Redirect(Request.RawUrl) to get out of postback and reload the page. Or else wrap it in an ajax UpdatePanel so it does and ajax postback.

Hope it helps,

Joe

11/26/2009 7:19:10 AM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Hi Joe

Thank you for that. Would you do the codebehind in a codebehind file then or just at the top of the VB.Net UserControl?

Also, I've never used the Response.Redirect(Request.RawURL) before - would I put this just after sending my mail, typically where I'd have a "Thank You" label set to become visible?

Thank you again.

11/26/2009 9:05:47 AM
Gravatar
Total Posts 18439

Re: Sending a form which is outside of the mojo CMS

If you use an ajax UpdatePanel then it would be easier to show a thank you message. The problem is with a full postback it can affect other features on the page until you get out of postback by redirecting and if you don't redirect out of postback then if the user clicks the refresh button it posts the form again.

If you redirect, yes do it right after executing whatever logic you need for sending mail but with a redirect there is no good method to show a thank you because the redirect makes a new request and knows nothing about the previous request, so probably better to use an UpdatePanel. Note there are built in methods to make sending mail easier, see this thread

To use codebehind, you would want to put your controls in a custom project not directly in the mojoPortal projects and then you would use a post build event to copy your stuff up to the Web. If you just use inline code with <script runat="server" then you can just drop your control into a folder without it actually being part of the mojoPortal project.

Hope it helps,

Joe

11/27/2009 7:57:54 AM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Cheers Joe, that's great. Never used Ajax before so this'll be fun....

Any on site docs regarding the update panel??

Thanks

11/27/2009 9:26:39 AM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Hi Joe

Just tried this out using a new VB User Control which I registered in layout.master and then dropped into my page. My dev skills aren't good enough to get this working so I'm wondering if you know of any examples out there I could look at please? Just a simple "name & email" form example would be great as a starting point.

Thanks

11/28/2009 6:29:50 AM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Hi Joe, again! Smile

I'm considering whether I can use your paid for Form Wizard extension for this now and integrate the form into the CMS - in the longterm it'll likely be far better.

That said I don't know if i'd be able to style the form the same as I've applied custom classes to it and images for the button etc.

Could you advise please? This is my CSS for the form:

/* quote form */

.formhead, .leftside{ font-weight:bold;font-size:18px; color:#004812; line-height:30px; }

.formsubhead{ font-weight:bold;font-size:14px; color:#004812; line-height:30px; }

#quoteForm{background-image:url(img/bgform.gif); background-repeat:repeat-x; padding-left:17px; height:440px; margin-bottom:3px;}

#col1 li{clear:both;}

#col1 .inputstyle{background-image:url(img/inputbg.gif); width:190px; height:20px; line-height:10px; padding-left:10px; margin-bottom:4px; }

#col1 .checkstyle{ height:18px;}

#col1 .textareastyle{ background-image:url(img/textareabg.gif); width:192px; height:67px; line-height:10px; padding-left:8px; padding-top:3px;margin-bottom:4px;}

#col1 .labelin{ font-weight:bold;font-size:10px; color:#004812;}

#col1 .labeltext{ font-weight:bold;font-size:10px; color:#004812; line-height:8px; padding-left:2px;height:30px;}

.labelcheck{ font-weight:bold;font-size:10px; color:#004812; line-height:11px; float:left;}

.textin{ font-size: 10px; background-color: #ffffff; border: 1px solid #ffffff; margin-top:1px; margin-left:2px;}

#col1 textarea{ font-size: 10px; background-color: #ffffff; border: 1px solid #ffffff; height:45px; width:180px; margin-top:5px; }

#col1 .check{ margin:0px; padding:0px; width:15px;height:15px; background-color:#ffffff; margin-right:5px; float:left;}

.name{width:150px;}

.company{width:133px;}

.email{width:150px;}

.tel{width:128px;}

.news1{float:left; width:17px; }

.news2{float:left;width:143px;}

.submit{float:left; width:40px; }

/* end quote form */

If I can make it look exactly the same I'll be up for getting that component without a doubt.

Thank you.

Mark

11/28/2009 6:44:25 AM
Gravatar
Total Posts 18439

Re: Sending a form which is outside of the mojo CMS

Hi Mark,

The Form Wizard can be styled with CSS but I cannot promise that you can make it exactly as you have styled your custom form.

It provides different css classes per each question type (you must use classes it provides you cannot add your own) that can be used to style questions by their type but currently does not offer per question css classes. You could use id selectors to select specific items but the ids themselves are very long partly because of asp.net and partly because I use the question guid as part of the id, still it could be done.

I would recommend experiment on the demo site creating a form and then copy the rendered markup to a local html file and experiment to see if you can style it as you wish.

Note also though that I do not recommend using the Form Wizard directly inside the layout.master file and do not think it will work correctly like that, it should be added to a page like other features.

When I get a chance I will make VB.NET versions of my Hello World examples and maybe that will help you implement your custom form, but I am extremely busy so not sure how soon I will be able to get to it.

Best,

Joe

11/29/2009 10:27:38 AM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Hi Joe

Thank you for that, I'll try out the demo form wizard and check out the rendered html. As for putting it into the layout.master, I didnt have it down to do that, I'm just going to replace my static html form with the left side panel from mojo and then publish that out to every page on the site.

VB.Net examples would be great, whenever you can squeeze it in of course! :0)

May be back...

Thanks again.

Mark

11/30/2009 6:02:01 AM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Hi Joe

I need a quick interim solution for this whilst I work on a longer term fix and amends to the overall skin to integrate the form wizard. The client needs it live, so I'm wondering; could I use and iframe in place of my form now and then load a VB coded .Net page within and carry out all of my logic from there? It wouldn't send the postback for the entire CMS would it if I submitted via the iframe?

Messy fix but a quick one to get them running whilst I work on the better solution...

Thanks

Mark

11/30/2009 11:12:55 AM
Gravatar
Total Posts 2239

Re: Sending a form which is outside of the mojo CMS

Hi Mark,

You may want to take a look at jQuery Load (http://docs.jquery.com/Ajax/load). It is a lot cleaner than an iFrame because the user isn't trapped inside the frame. I have used it in the past to do things similar to what you are doing although the forms were PHP, not .NET.

HTH,
Joe D.

11/30/2009 12:44:44 PM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Hi Joe

That jQuery works great, thank you.

I'm up against another issue now; I've never used an Ajax Update Panel so I've not tried it in this instance. So instead I have this site www.russellrichardson.co.uk which is using jquery ajax load to pull in the form on the left which in turn is housed here: www.russellrichardson.co.uk/Data/Sites/1/skins/russellrichardson-newform/quoteforminline.aspx.

Works great as far as loading goes, but I've put a label in to test and made it invisible beneath the submit button. I then have this code on my button click (in page script):

Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)

label1.Visible = True

End Sub

So that I can check the postback etc with the simple label before getting it to mail my form later.

However, when I click submit the form tries to redirect me somehow or why to www.russellrichardson.co.uk/quoteforminline.aspx (which of course isn't there) and throws a 404 error. I guess it's because it's posting the entire page back to the server (hence why I was going to use an iframe)

I tried putting Response.Redirect(Request.RawUrl) after making my label visible, with the same result.

Can you see a solution for this by any chance?

Thanks

Mark

11/30/2009 4:28:56 PM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

Oh by the way - the site has now reverted back to the "normal" skin where the form does nothing. The scenario i described above happens on the development skin...

Mark

12/1/2009 9:07:58 AM
Gravatar
Total Posts 2239

Re: Sending a form which is outside of the mojo CMS

Hi Mark,

So I think the advantage I mentioned of using jQuery Load is actually a disadvantage for you in this case. Your best bet is to develop a feature which contains the form and all the logic to process it properly. If you don't want to do that, I think you are stuck with an iFrame.

HTH,
Joe D.

12/1/2009 1:53:15 PM
Gravatar
Total Posts 160
mojoPortal Community Expert
Designer of over 25 unique and custom mojoPortal sites with DMSQD and sister company, The Design Loft - www.dmsqd.com

Re: Sending a form which is outside of the mojo CMS

 Sorted it with an iframe guys - thank you for your help and advice.

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