funa 12. 3. 2010 10:39:41 Body: 1575 Najaktívnejší č.: 18 textbox + lostfocus Caute. Viem nejak odchytit asp:Textbox ... LostFocus, a priradit mu nejaku metodu v kode? [Reakcia]
T 12. 3. 2010 11:18:54 Body: 16750 Najaktívnejší č.: 2 RE: textbox + lostfocus @funa: bolo by treba doimplementovat do textboxu, nie je to tazke....trik je pridat onblur atribut do neho volanie __dopostback s tagetom samym controlom a po postbacku firenut zodpovedajuci event...vecer Ti to urobim, ak budem mat cas Tomáš Zeman, MCSD.NET, MCPD [Reakcia]
T 13. 3. 2010 21:39:06 Body: 16750 Najaktívnejší č.: 2 RE: textbox + lostfocus Ahoj, neviem ci je to este aktualne...ale paci...public class TextBox : System.Web.UI.WebControls.TextBox ,IPostBackEventHandler...{ public event EventHandler<EventArgs> Blur; protected virtual void OnBlur(EventArgs args) ...{ if (Blur != null) Blur(this, args); } protected override void AddAttributesToRender(HtmlTextWriter writer) ...{ base.AddAttributesToRender(writer); if (AutoPostBack && Page != null && Page.Request.Browser.EcmaScriptVersion.Major >= 1) ...{ PostBackOptions options = new PostBackOptions(this, "blur"); options.AutoPostBack = Page.Form != null; options.PerformValidation = true; options.ValidationGroup = ValidationGroup; writer.AddAttribute("onblur", Page .ClientScript .GetPostBackEventReference(options, true)); } } public void RaisePostBackEvent(string eventArgument) ...{ if (eventArgument == "blur") OnBlur(new EventArgs()); }}<my:TextBox runat="server" AutoPostBack="true" ID="MyTextBox" OnBlur="MyTextBox_Blur" /> Tomáš Zeman, MCSD.NET, MCPD [Reakcia]
funa 14. 3. 2010 13:36:47 Body: 1575 Najaktívnejší č.: 18 RE: textbox + lostfocus ok super. diky moc............. [Reakcia]
T 14. 3. 2010 16:04:10 Body: 16750 Najaktívnejší č.: 2 RE: textbox + lostfocus @funa: tu je fix, stale je tam problem, ze sa server side firene textchanged pred blurom, viem patchnut aj to, ale nie je to moc pekne :-D public class TextBox : System.Web.UI.WebControls.TextBox,IPostBackEventHandler...{private const stringBLUR_DHMTL_EVENT = "onblur",BLUR_CHANGE_EVENT = "onchange",BLUR_EVENT_ARGS = "blur";public event EventHandler<EventArgs> Blur;protected virtual void OnBlur(EventArgs args)...{if (Blur != null)Blur(this, args);} protected override void AddAttributesToRender(HtmlTextWriter writer)...{Page page = Page;bool applyBlurEvent= AutoPostBack&& Blur != null&& page != null&& page.Form != null //error is thrown anyway&& page.Request.Browser.EcmaScriptVersion.Major >= 1;string currentBlurJS = String.Empty;if (applyBlurEvent)...{string currentChangeJS = String.Empty;if (HasAttributes)...{currentBlurJS = Attributes[BLUR_DHMTL_EVENT];if (!String.IsNullOrEmpty(currentBlurJS))...{if (!currentBlurJS.EndsWith(";"))currentBlurJS += ";";Attributes.Remove(BLUR_DHMTL_EVENT);}currentChangeJS = Attributes[BLUR_DHMTL_EVENT];if (!String.IsNullOrEmpty(currentChangeJS))...{if (!currentChangeJS.EndsWith(";"))currentChangeJS += ";";}}//ensure onchange won't postbackAttributes["onchange"]= currentChangeJS + "return false;";}base.AddAttributesToRender(writer);if(applyBlurEvent)...{ PostBackOptions options =new PostBackOptions(this, BLUR_EVENT_ARGS);options.AutoPostBack = true;options.PerformValidation = true;options.ValidationGroup = ValidationGroup;string blurJS = currentBlurJS + page.ClientScript.GetPostBackEventReference(options, true);writer.AddAttribute(BLUR_DHMTL_EVENT, blurJS); }}public void RaisePostBackEvent(string eventArgument)...{if (eventArgument == BLUR_EVENT_ARGS)OnBlur(new EventArgs());}}Inak ten bazovy AddAttributesToRender je dost zly napisany :-( Tomáš Zeman, MCSD.NET, MCPD [Reakcia]
T 14. 3. 2010 16:07:09 Body: 16750 Najaktívnejší č.: 2 RE: textbox + lostfocus Mea culpa - mea maxima culpa :-)) public class TextBox : System.Web.UI.WebControls.TextBox,IPostBackEventHandler...{private const stringBLUR_DHMTL_EVENT = "onblur",BLUR_CHANGE_EVENT = "onchange",BLUR_EVENT_ARGS = "blur";public event EventHandler<EventArgs> Blur;protected virtual void OnBlur(EventArgs args)...{if (Blur != null)Blur(this, args);} protected override void AddAttributesToRender(HtmlTextWriter writer)...{Page page = Page;bool applyBlurEvent= AutoPostBack&& Blur != null&& page != null&& page.Form != null //error is thrown anyway&& page.Request.Browser.EcmaScriptVersion.Major >= 1;string currentBlurJS = String.Empty;if (applyBlurEvent)...{string currentChangeJS = String.Empty;if (HasAttributes)...{currentBlurJS = Attributes[BLUR_DHMTL_EVENT];if (!String.IsNullOrEmpty(currentBlurJS))...{if (!currentBlurJS.EndsWith(";"))currentBlurJS += ";";Attributes.Remove(BLUR_DHMTL_EVENT);}currentChangeJS = Attributes[BLUR_CHANGE_EVENT];if (!String.IsNullOrEmpty(currentChangeJS))...{if (!currentChangeJS.EndsWith(";"))currentChangeJS += ";";}}//ensure onchange won't postbackAttributes["onchange"]= currentChangeJS + "return false;";}base.AddAttributesToRender(writer);if(applyBlurEvent)...{ PostBackOptions options =new PostBackOptions(this, BLUR_EVENT_ARGS);options.AutoPostBack = true;options.PerformValidation = true;options.ValidationGroup = ValidationGroup;string blurJS = currentBlurJS + page.ClientScript.GetPostBackEventReference(options, true);writer.AddAttribute(BLUR_DHMTL_EVENT, blurJS); }}public void RaisePostBackEvent(string eventArgument)...{if (eventArgument == BLUR_EVENT_ARGS)OnBlur(new EventArgs());}} Tomáš Zeman, MCSD.NET, MCPD [Reakcia]
funa 15. 3. 2010 8:41:34 Body: 1575 Najaktívnejší č.: 18 RE: textbox + lostfocus No fajn. Diky moc. A za sa vola textchanged skor mi nevadi :) [Reakcia]