events - ASP.net control Postback Problem (Can't read the value the user entered!) -


i've written custom widget allow user select location database of locations. first asp.net custom control. seemed working fine, there's problem.

my control implements raisepostbackevent function follows:

public void raisepostbackevent(string eventargument) {     selectedlocationid = eventargument.split('|')[0];     selectedlocationdescription = eventargument.split('|')[1]; } 

i wrote test page , included following in asp code:

<%= locationselector.selectedlocationid %> 

that worked fine.

however, in web application, following code not work:

    protected void page_load(object sender, eventargs e)     {         if (page.ispostback)          response.write(locationselector.selectedlocationid);          // selectedlocationid null here!!!     } 

when run code in debugger, see page load event fires before post event! therefore, data not yet read postback. know using ms provided text field control, text available @ page load, think must doing wrong.

how can read location user selected when page load event fires? clarify, i'm refering page load of web application page.

you're setting selectedlocationid on postback event , @ same time trying retrieve value on first load. selectedlocationid null right.

try:

protected void page_load(object sender, eventargs e)     {        if (locationselector != null)          response.write(locationselector.selectedlocationid);     } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -