iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > Community > The Café

Reply
 
LinkBack (1) Thread Tools
Old January 29th, 2007, 08:35 AM   1 links from elsewhere to this Post. Click to view. #1
flyingHigh
Guest
 

Posts: n/a
Angry IPostBackDataHandler.LoadPostData never called

I am replacing a standard asp:TextBox control with a custom control. Everything works except that the value entered does is not retained when the page is submitted by the server ( via a separate submit button ). I set a breakpoint in the LoadPostData method and discovered that it never gets called. The same aspx page works fine if I go back to using the asp:TextBox control. What am I doing wrong? Any help will be appreciated.

Here is my control code:

[ToolboxData("<{0}:TextBoxEx runat=server></{0}:TextBoxEx>")]
public class TextBoxEx : System.Web.UI.WebControls.TextBox, IPostBackDataHandler

{

#region Properties

private string m_onchange;
private string m_size;
private string m_DataField;


public string onchange
{
set { m_onchange = value; }
}

public override string Text
{
get
{
return (ViewState["Text"]==null) ? base.Text : (string) ViewState["Text"];
}
set { ViewState["Text"]=value; }
}

public string Size
{
set { m_size = value; }
}

#endregion
#region Render

/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>

protected override void Render(HtmlTextWriter output)
{
RenderInputTag(output);
}

private void RenderInputTag(HtmlTextWriter htw)
{
htw.AddAttribute(HtmlTextWriterAttribute.Value,Tex t);
if (m_onchange != null) htw.AddAttribute(HtmlTextWriterAttribute.Onchange, m_onchange);
if (this.CssClass != "") htw.AddAttribute(HtmlTextWriterAttribute.Class,Css Class);
if (this.MaxLength != 0) htw.AddAttribute(HtmlTextWriterAttribute.Maxlength ,MaxLength.ToString());
htw.AddAttribute(HtmlTextWriterAttribute.Tabindex, TabIndex.ToString(NumberFormatInfo.InvariantInfo)) ;
htw.AddAttribute(HtmlTextWriterAttribute.Size,m_si ze);
// if (this.ReadOnly) htw.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "readonly");

htw.RenderBeginTag(HtmlTextWriterTag.Input);
htw.RenderEndTag();
}

#endregion Render

#region IPostBackDataHandler *** This code is never called

bool IPostBackDataHandler.LoadPostData(
string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection)
{
string presentValue = Text;
string postedValue = postCollection[this.UniqueID];

if (!presentValue.Equals(postedValue))
{
Text = postedValue;
return true;
}
return false;
}

void IPostBackDataHandler.RaisePostDataChangedEvent()
{
}
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks

Tags
controls , custom , ipostbackdatahandler , loadpostdata , textbox


LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/the-caf/17511-ipostbackdatahandler-loadpostdata-never-called.htm
Posted By For Type Date
custom control loadPostData - ng.asp-net-forum.windows-hosting_open_forum - fix error problem @CodeVerge This thread Refback November 8th, 2008 04:19 AM

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] why onclick is not called - Help Please ashishmishra16 JavaScript 2 November 16th, 2007 03:02 AM
Login prompt when not called EXDunk Flash and ActionScript 0 February 26th, 2007 05:37 PM
not sure what its called but i can show you what i mean bruno89 HTML, XHTML and CSS 12 October 17th, 2006 04:15 AM
i dont know what its called but i can show you what i mean lol bruno89 HTML, XHTML and CSS 20 August 26th, 2006 01:13 PM


Search Engine Optimization by vBSEO 3.2.0 RC8