Hello, I finally managed to create a custum guestbook. I succesfully runned it locally on my computer.
Also i downloaded new mojoportal source code and tried there my custom guestbook-code, it worked fine!
I now uploaded my custom compiled package to my online website. I ran setup in my webpage. My guestbook was showing up within the features-menu. I added it to my page and it works fine. I can post messages to my guestbook and i can see them.
The only problem is the paging. Locally on my computer it works great, but online my guestbook-messages don't show up. The error-log from my website shows no errors. What is wrong?
This is my code:
namespace HvN.Web.Ui
{
public partial class GuestbookModuleModule : SiteModuleControl
{
// FeatureGuid 806bc73c-f1cc-45b2-af4d-cee989976b59
#region OnInit
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Load += new EventHandler(Page_Load);
MyDataGrid.PageIndexChanged += new DataGridPageChangedEventHandler(MyDataGrid_Page);
btnSubmit.Click += new EventHandler(this.btnSubmit_Click);
}
#endregion
//string strMessageSurround, strMessageMiddle, strGuestBookName;
protected void Page_Load(object sender, EventArgs e)
{
LoadSettings();
PopulateLabels();
PopulateControls();
if (!Page.IsPostBack) { bindGridhans(); }
}
private void PopulateControls()
{
TitleControl.EditUrl = SiteRoot + "/GuestbookModule/GuestbookModuleEdit.aspx";
TitleControl.Visible = !this.RenderInWebPartMode;
if (this.ModuleConfiguration != null)
{
this.Title = this.ModuleConfiguration.ModuleTitle;
this.Description = this.ModuleConfiguration.FeatureName;
}
}
private void PopulateLabels()
{
TitleControl.EditText = "Edit";
}
private void LoadSettings()
{
captcha.ProviderName = siteSettings.CaptchaProvider;
captcha.Captcha.ControlID = "captcha" + ModuleId;
captcha.RecaptchaPrivateKey = siteSettings.RecaptchaPrivateKey;
captcha.RecaptchaPublicKey = siteSettings.RecaptchaPublicKey;
}
void bindGridhans()
{
string strSQL = "SELECT id, name, message, TheDate FROM messages ORDER BY TheDate DESC;";
SqlConnection objConnection = new SqlConnection(ConfigurationManager.AppSettings["MSSQLConnectionString"]);
SqlDataAdapter objAdapter = new SqlDataAdapter(strSQL, objConnection);
DataSet objDataSet = new DataSet();
objAdapter.Fill(objDataSet, "messages");
DataView objDataView = new DataView(objDataSet.Tables["Messages"]);
MyDataGrid.DataSource = objDataView;
MyDataGrid.DataBind();
}
void MyDataGrid_Page(object sender, DataGridPageChangedEventArgs e)
{
MyDataGrid.CurrentPageIndex = e.NewPageIndex;
bindGridhans();
}
void btnSubmit_Click(object sender, EventArgs e)
{
Page.Validate();
if (!Page.IsValid) { return; }
// using .Replace("'", "") to remove naughty single quote
string sName = Server.HtmlEncode(txtName.Text.Replace("\'", ""));
string sEmail = Server.HtmlEncode("Niks".Replace("\'", ""));
string sMessage = Server.HtmlEncode(txtMessage.Text.Replace("\'", ""));
SqlConnection objConnection = new SqlConnection(ConfigurationManager.AppSettings["MSSQLConnectionString"]);
SqlCommand objCmd;
string DateTime;
// Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL")
DateTime = System.DateTime.Now.ToString("M-dd-yyyy HH:mm:ss:fff");
string strSQL = ("INSERT INTO messages (name, email, message, thedate) VALUES (\'"
+ (sName + ("\', \'"
+ (sEmail + ("\', \'"
+ (sMessage + ("\', \'"
+ (DateTime + "\')"))))))));
objConnection.Open();
objCmd = new SqlCommand(strSQL, objConnection);
objCmd.ExecuteNonQuery();
objConnection.Close();
// Response.Redirect("guestbook.aspx")
bindGridhans();
}
public string smileFilter(string smiles)
{
smiles = smiles.Replace("[angel]", "
");
smiles = smiles.Replace("[angry]", "
");
return smiles;
}
public string swearFilter(string swears)
{
string strSQL = "SELECT badword, replacement FROM badwords";
SqlConnection objConnection = new SqlConnection(ConfigurationManager.AppSettings["MSSQLConnectionString"]);
SqlCommand ObjCommand = new SqlCommand(strSQL, objConnection);
SqlDataReader objDataReader;
objConnection.Open();
objDataReader = ObjCommand.ExecuteReader();
while (objDataReader.Read())
{
//swears = swears.Replace(objDataReader["badword"].ToString, objDataReader["replacement"].ToString);
}
objDataReader.Close();
objConnection.Close();
return swears;
}
}
}
<%@ Control Language="C#" AutoEventWireup="false" CodeBehind="Guestbookandsign_ascx.ascx.cs" Inherits="HvN.Web.Ui.GuestbookModuleModule" %>
<%----%>
<%----%>
<%--
--%>
<%&&
<%# ((System.Data.DataRowView)Container.DataItem)["TheDate"] %> |
<%# smileFilter(String.Format("{0}", DataBinder.Eval(Container.DataItem, "message")))%>
|
<%# ((System.Data.DataRowView)Container.DataItem)["name"]%> |
<%--
--%>
Je Naam:* | |
Je E-mail adres:* | |
Je Bericht:* |
|
|
|
<%----%>
<%--
--%>
<%----%>
<%--
--%>