I created a new .net user control in .net framework 2.0 and tried to access the same from the CMS by creating the macros. I am able to import into the same into the RUNAWAY module.
The page_load event of the user control is working fine and i placed an button in the user control and written the code to change the text of an literal when the button is clicked.
The button click event is not getting executed in the CMS pages.
Hi this should work in your usercontrol also. Did you assign the event handler? If so, set a breakpoint in the button click event handler code and attach the debugger in visual studio to see what happens.
I created the user control in the visual studio IDE and placed the same in the aspx page in the same solution and it is working perfect in that.The same if i copy into the CME, button click event is not getting fired.
I am having almost exactly the same problem. The button click does not seem to be causing a postback (therefore the debugger does not fire). This is happening for two user controls on my content page. My code is almost identical to the code listed here.
I find this very strange never experienced this. If you set a breakpoint at page_load, that gets hit? even after postback? Also try to load the page with queryparameter ?umbdebugshowtrace=true to see if you have any errors on the page.
I faced similar problem. See this http://bit.ly/bPfxG8 for complete
details. The link button if used under Umbraco will case ASP.NET event
model to misbehave.
please help me any one. My code is above and button click event is not working in IE and opera.It's working fine in Mozila and google crome.It's working fine in all browser's before it create micro and attach it to my application.
I am having the exact same problem. I have a usercontrol with a button on that I have subscribed to the onClick event of. The user control works fine in a normal asp.net page. When placed in an umbraco page the page_load event fires but not the button onClick event.
There are no asp errors shown on the page. There are no errors shown when using the umbDebugShowTrace=true option. Everything is encapsulated within a single <form runat="server"> tag.
I have tried the user control in a blank umbraco page with a blank template to ensure there are no issues created by my template.
Does anyone have any ideas as to why this would be?
I'm having the same problem. I just have a textbox and button and a literal. When you click the button it just sets the literal to the text in the texbox, but when I run it in umbraco the button doesn't cause a post back. Did anyone ever figure out how to make this work?
.Net user control button click events not working
Hi All,
I created a new .net user control in .net framework 2.0 and tried to access the same from the CMS by creating the macros. I am able to import into the same into the RUNAWAY module.
The page_load event of the user control is working fine and i placed an button in the user control and written the code to change the text of an literal when the button is clicked.
The button click event is not getting executed in the CMS pages.
Waiting for the responses.
Thanks,
Vishnu
Hi this should work in your usercontrol also. Did you assign the event handler? If so, set a breakpoint in the button click event handler code and attach the debugger in visual studio to see what happens.
Cheers,
Richard
Hi
I created the user control in the visual studio IDE and placed the same in the aspx page in the same solution and it is working perfect in that.The same if i copy into the CME, button click event is not getting fired.
Thanks,
Vishnu
I'm curious how you wired up the event handlers, It shouldn't make any difference. Can you post the ascx and code behind code?
Cheers,
Richard
Hi Richard,
Thanks for the reply.
I am hereby sending the code which i have used.
Thanks,
Vishnu
-------------------------------------------------------------------------------------
UCSample1.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCSample1.ascx.cs" Inherits="UCSample2.UCSample1" %>
Hello World 2<p>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</p>
<p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</p>
<p>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</p>
UCSample1.ascx.cs
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace UCSample2
{
public partial class UCSample1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Literal1.Text = "test data page load";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Literal1.Text = "You entered : " + TextBox1.Text;
}
}
}
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="UCSample2._Default" %>
<%@ Register src="UCSample1.ascx" tagname="UCSample1" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:UCSample1 ID="UCSample11" runat="server" />
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace UCSample2
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
I am having almost exactly the same problem. The button click does not seem to be causing a postback (therefore the debugger does not fire). This is happening for two user controls on my content page. My code is almost identical to the code listed here.
I find this very strange never experienced this. If you set a breakpoint at page_load, that gets hit? even after postback? Also try to load the page with queryparameter ?umbdebugshowtrace=true to see if you have any errors on the page.
Cheers,
Richard
I faced similar problem. See this http://bit.ly/bPfxG8 for complete details. The link button if used under Umbraco will case ASP.NET event model to misbehave.
Tarek.
Hello all,
I am getting same problem.User control .ascx contain one texbox and one button control.Validation is working fine but click event is not working.
Ajay Kanwar
Do you have example of your code syntax?
You want to make sure that you are not altering the code on "postback".
Dear my code in .ascx page is:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MKFANewLetterHome.ascx.cs" Inherits="NewsLetterHome.MKFANewLetterHome" %>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=txtEmail.ClientID %>').watermark('Email Address', { className: 'watermark' });
});
$('#<%=txtEmail.ClientID %>').mousedown(function () {
$.watermark.hide($('#<%=txtEmail.ClientID %>'));
});
</script>
<style type="text/css">
.watermark
{
color: #999;
}
.redqired
{
color:red;
}
</style>
<div class="newsLetterDetails">
<span id="newsLetterEmail" style="float:left;margin-top:8px" >
<asp:TextBox ID="txtEmail" runat="server"
Width="150px" CssClass="newsLetterEmail watermark"
ValidationGroup="News"></asp:TextBox>
<asp:RequiredFieldValidator
ID="rfvEmail" runat="server" ErrorMessage="Email"
ControlToValidate="txtEmail" ValidationGroup="News"><span class="redqired">*</span></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="rgvEmail" runat="server"
ErrorMessage="Email Address only" ControlToValidate="txtEmail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="News"><span class="redqired">*</span></asp:RegularExpressionValidator>
<asp:Label ID="lblMesageEmail" runat="server" Text="" Visible="False"></asp:Label>
</span>
<span id="newsLetterGo" style="float:left;margin-top:8px">
<asp:ImageButton ID="imgNewsLetter" runat="server"
ImageUrl="../umbraco/images/Media/NewsLatter.png"
CssClass="imgNewsLatter" onclick="imgNewsLetter_Click"
ValidationGroup="News" /> </span></br>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" CssClass="redqired"
ValidationGroup="News" />
</div>
-------------------------------------------------------------------------------------------------------------------------------------------------------
and .cs is:
private string EmailAddress;
public string _EmailAddress
{
get;
set;
}
protected void Page_Load(object sender, EventArgs e)
{
}
private static SqlConnection GetConnection()
{
SqlConnection oConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
return oConnection;
}
protected int SendMailToMKFencing(string newLetterName)
{
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("UserId");
mailMessage.To.Add("UserId");
mailMessage.Bcc.Add(_EmailAddress.Trim());
mailMessage.Subject ="News Letter";
Attachment attachNewsLetter = new Attachment(Server.MapPath("/umbraco/images/UploadNewsLetter/" + newLetterName.Trim()));
mailMessage.Attachments.Add(attachNewsLetter);
mailMessage.Body ="Body Message";
// mailMessage.IsBodyHtml = true;
SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential("UserID", "password");
int mailStatus = 0;
try
{
smtpClient.Send(mailMessage);
mailStatus = 1;//Mail send
}
catch (Exception err)
{
throw err;
mailStatus = 0;
}
finally
{
mailMessage = null;
smtpClient = null;
}
return mailStatus;
}
protected void imgNewsLetter_Click(object sender, ImageClickEventArgs e)
{
if (txtEmail.Text != "")
{
_EmailAddress = txtEmail.Text.Trim();
SqlConnection oConnection = GetConnection();
SqlCommand oCommand = new SqlCommand();
oCommand.Connection = oConnection;
oCommand.CommandType = CommandType.StoredProcedure;
oCommand.CommandText = "sp_Name";
oCommand.Parameters.AddWithValue("@Email", _EmailAddress);
string newLetterName = "";
try
{
oConnection.Open();
newLetterName = Convert.ToString(oCommand.ExecuteScalar());
}
catch (Exception err)
{
throw err;
}
finally
{
oConnection.Close();
oConnection.Dispose();
oCommand.Dispose();
}
if (newLetterName.Trim() == "00")
{
txtEmail.Visible = false;
lblMesageEmail.Visible = true;
imgNewsLetter.Visible = false;
lblMesageEmail.Text = "Our team contact you.";
}
else if (newLetterName.Trim() == "")
{
Response.Redirect("/1187", false);
}
else
{
int mailClientStatus = SendMailToMKFencing(newLetterName);
if (mailClientStatus == 1)
{
lblMesageEmail.Text = "News letter has been sucessfully sent!";
txtEmail.Visible = false;
lblMesageEmail.Visible = true;
imgNewsLetter.Visible = false;
txtEmail.Text = "";
}
}
}
}
This code is working fine in mozila and google crome.Butit's not working in IE any version or Opera.
please help me any one. My code is above and button click event is not working in IE and opera.It's working fine in Mozila and google crome.It's working fine in all browser's before it create micro and attach it to my application.
where is your code?
thanks for response,In page 1
Please help me any one.I am still in problem.
Don't forget to put your form inside a <form runat="server"> </form> pair of tags or you won't trigger a postback properly.
This can be solved by disabling any control using PostBackUrl since they mess with postbacks in general in Umbraco
Simply search your project for any references to PostBackUrl and disable them, they are a no use in umbraco.
I am having the exact same problem. I have a usercontrol with a button on that I have subscribed to the onClick event of. The user control works fine in a normal asp.net page. When placed in an umbraco page the page_load event fires but not the button onClick event.
There are no asp errors shown on the page. There are no errors shown when using the umbDebugShowTrace=true option. Everything is encapsulated within a single <form runat="server"> tag.
I have tried the user control in a blank umbraco page with a blank template to ensure there are no issues created by my template.
Does anyone have any ideas as to why this would be?
I'm having the same problem. I just have a textbox and button and a literal. When you click the button it just sets the literal to the text in the texbox, but when I run it in umbraco the button doesn't cause a post back. Did anyone ever figure out how to make this work?
is working on a reply...