I created a web part and there are five configurations: in the usercontrol.ascx, I get the values by the following code:
namespace tasks_email.tasks_email_webpart
{
public partial class tasks_email_webpartUserControl : UserControl
{
public tasks_email_webpart WebPart { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_send_id_Click(object sender, EventArgs e)
{
string subject = " ";
subject = this.WebPart.SUBJECT as string;
string emailAddrS = " ";
emailAddrS = this.WebPart.EMAILADDR as string;
string checkout_changes = " ";
checkout_changes = this.WebPart.CHECKOUTLISTSNAMES as string;
SendCheckout("bo.wang@us.bnpparibas.com", subject, "this is a project test");
But when I clicked the button, it said: null reference exception, the variable cannot get the SUBJECT value no matter what stuff I editted the configuration
Can any body tell me how to handle that?
*I checked the webpart.cs, I did write like:
namespace tasks_email.tasks_email_webpart
{
[ToolboxItemAttribute(false)]
public class tasks_email_webpart : Microsoft.SharePoint.WebPartPages.WebPart
{
[WebBrowsable(true), Category("Configurations"), Personalizable(PersonalizationScope.Shared), WebDisplayName("Subject")]
public string SUBJECT { get; set; }
in ascx I created a button with the method:
<asp:Button ID="btn_send_id" runat="server" Text=" Email_changes "
onclick="btn_send_id_Click" CssClass="Search_Submit" onclientclick="return checkna()"
/>
the error report:
[NullReferenceException: Object reference not set to an instance of an object.]
tasks_email.tasks_email_webpart.tasks_email_webpartUserControl.btn_send_id_Click(Object sender, EventArgs e) +375
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +114
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +139
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +28
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2980