problem enterprising controls .net


problem enterprising controls



hello all,



i'm wanting emanate enterprising controls, have insist viewstate opposing page loads. easy enough, right? i have re-create controls on any page load, controlling same ids. however, here's locate - prerender event, i'm wanting pristine controls collection, following reconstruct enterprising controls new values. reasons complicated, substantially take me page explain since i wish it. so, interests brevity, let's only assume i definitely contingency this, there's way.



the problem comes after i re-create controls prerender event. re-created controls never bond viewstate, values insist opposing page loads. i don't know since happens. i'm already re-creating controls onload event. i this, newly combined controls bond viewstate only fine, presumption i same ids each time. however, i try same thing prerender event, fails.



in any case, here instance formula :



namespace testframework.webcontrols
{



public category valuelinkbutton : linkbutton
{
open twine value
{
get
{
relapse (string)viewstate[id + "vlbvalue"];
}

set
{
viewstate[id + "vlbvalue"] = value;
}
}
}

public category testcontrol : webcontrol
{
stable overrule vacant onload(eventargs e)
{
base.onload(e);

controls.clear();

valuelinkbutton templink = null;

templink = new valuelinkbutton();
templink.id = "valuelinkbutton";
templink.click += new eventhandler(value_click);

(!page.ispostback)
{
templink.value = "old value";
}

controls.add(templink);
}

stable overrule vacant onprerender(eventargs e)
{
base.onprerender(e);

valuelinkbutton templink = ((valuelinkbutton)findcontrol("valuelinkbutton")); //[case 1]

//valuelinkbutton templink = new valuelinkbutton(); [case 2]

templink.id = "valuelinkbutton";
templink.value = "new value";
templink.text = "click";

controls.clear();
controls.add(templink);
}

vacant value_click(object sender, eventargs e)
{
page.response.write("[" + ((valuelinkbutton)sender).value + "]");
}
}


}



so, let's inspect box 1, where line unbroken [case 1] commented out, nonetheless line unbroken [case 2] commented out. here, all works only fine. i put control page bucket page, i couple says "click". i click link, page outputs calm "[new value]", unbroken line, informed "click" link. each subesquent i click "click" link, same thing. far, good.



but let's inspect box 2, where line unbroken [case 1] commented out, nonetheless line unbroken [case 2] commented out. here run problems. bucket page, "click" link. however, i click link, page outputs calm "[]" instead "[new value]". click eventuality banishment normally. however, "new value" calm i indifferent value charge control does persisted. once again, bit perplexity me. come, i reconstruct control onload, everything's glorious dandy, nonetheless i reconstruct control prerender, value doesn't persisted?



i feel there simply proceed this. i re-create control prerender, there proceed bond newly combined control viewstate?



i've struggled days. any assistance give me appreciated.



thanks.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members