|
|
Rank: Enthusiast
Joined: 4/13/2007 Posts: 21
|
I am running version 3.0.0 on a site that has a macro for a .net user control with a public string. When I create the macro and click "Browse Properties" I can see the public string in the list and I added it to the properties tab of the macro. But for some reason when I put the macro into a template using the insert macro button I can pick the macro but the next page doesnt give me the option to assign a value to the parameter like it did in V2. So i just typed it into the template like this: Code:<?UMBRACO_MACRO macroAlias="ContactForm" ApplicationKeyAsString="72384792" /> This same exact control and macro code works fine in 2.0 but in my 3.0 site the parameter is never getting set. The conrol just cant see the value...Of course I triple check silly mistakes like spelling and such but to no avail. Any suggestions??
|
|
Rank: Devotee
Joined: 1/28/2007 Posts: 142
|
When you go to Developer->Macro->YourMacro and click on "properties", what kind of data types do your properties hold? Any way, here is a short sample of a usercontrol with properties (for a contact form) Code: using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls;
namespace UmbracoForms { public partial class ContactForm : System.Web.UI.UserControl { private string smtpauthusername; private string smtpauthpassword; private int smtpauthmode; private string smtpServer; private string mailTo;
public string SMTPAuthUsername { get { return smtpauthusername; } set { smtpauthusername = value; } }
public string SMTPAuthPassword { get { return smtpauthpassword; } set { smtpauthpassword = value; } }
public int SMTPAuthMode { get { return smtpauthmode; } set { smtpauthmode = value; } }
public string SMTPServer { get { return smtpServer; } set { smtpServer = value; } }
public string MailTo { get { return mailTo; } set { mailTo = value; } }
protected void Page_Load(object sender, EventArgs e) {
}
#region Web Form Designer generated code override protected void OnInit(EventArgs e) { InitializeComponent(); base.OnInit(e); }
private void InitializeComponent() { this.btnSend.Click += new System.EventHandler(this.btnSend_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion
private void btnSend_Click(object sender, System.EventArgs e) { try { // Build message System.Web.Mail.MailMessage mailMessage = new System.Web.Mail.MailMessage();
string msgBody = ""; mailMessage.From = "website@mySite.com"; mailMessage.To = mailTo; mailMessage.Subject = "A message from the site: " + txtSenderName.Text; // Define message format either text or html mailMessage.BodyFormat = System.Web.Mail.MailFormat.Html; msgBody += "<html>"; msgBody += "<head>"; msgBody += "<style>"; msgBody += "Body {font-family: Arial, Tahoma; font-size:12px;}"; msgBody += "</style>"; msgBody += "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"; msgBody += "</head>"; msgBody += "<body>"; msgBody += txtMessageBody.Text; msgBody += "</body>"; msgBody += "</html>"; mailMessage.Body = msgBody;
// Define SMTP server address or hostname //System.Web.Mail.SmtpMail.SmtpServer = smtpServer;
//SMTP Auth Support // Don't worry these don't actualy go to Microsoft there just fields. mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer); mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25); // SendUsing Local SMTP = 1 Network SMTP =2 mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2); // cdoAnonymous = 0 (do not auth) cdoBasic = 1 clear text, cdoNTLM = 2 mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", smtpauthmode); // Username & Password mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", smtpauthusername); mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", smtpauthpassword);
// Send mail System.Web.Mail.SmtpMail.Send(mailMessage);
txtPostMessage.Text = "Thank you. Your message has been sent successfully.";
} catch (Exception exp) { // Catch any other errors txtPostMessage.Text = exp.Message; } } } }
| Roni Biran | advansoft ltd | umbracist for a year give or take.... | waiting for CG08, missed the last one :no: |
|
|
Rank: Enthusiast
Joined: 4/13/2007 Posts: 21
|
Thx for the reply The data type I have chosen is "text". I have getters and setters on the properties that I need to be exposed. And the macro car see them so they must be exposed properly.
Still stumped...
|
|
Rank: Enthusiast
Joined: 4/13/2007 Posts: 21
|
So I figured out that if I take the UpdatePanel out of the .net control it starts working.
Does anyone have experience with using an UpdatePanel in their controls???
|
|
 Rank: Addict
Joined: 2/19/2007 Posts: 738 Location: Belgium
|
yup, just place a updatepanel and a contenttemplate around your control and the postbacks are gone Code: <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate>
</ContentTemplate> </asp:UpdatePanel>
Umbraco tips and tricks: http://www.nibble.be - umbraco mvp 08/09 - certified level 1 & 2 professional
|
|
Rank: Enthusiast
Joined: 4/13/2007 Posts: 21
|
Yea postbacks go away but then it stops reading in my parameter. If I take out the updatepanel it starts working again but with a full page refresh.
|
|
Rank: Enthusiast
Joined: 7/14/2007 Posts: 15
|
Stab in the dark:
Are you persisting the values between requests in your control? The reason I ask is that even though the entire Page isn't posting back, your control is. Maybe the macro can only pass the value on the first load.
A workaround could be to have hidden fields in your control. Use your properties to set the values of the hidden fields. The values should then be persisted between control postbacks.
|
|
Rank: Newbie
Joined: 11/4/2007 Posts: 1
|
Dude, ok sorry for doing this but I have no other way of contacting you. My name is Jack Vorves. I noticed your last name, I'd like to talk sometime (trying to find family).
|
|
|
Guest |