Ask a Question related to ASP.NET General, Design and Development.
-
Nathan Baulch #1
Manually get the text that a certain control posted when in IsPostBack mode...
I have a page with EnableViewState="false".
That page contains a DropDownList with dynamic items and a submit Button.
I need to get the SelectedIndex of the DropDownList on postback however all
I ever get is -1. This makes sense since on postback, the DropDownList is
now empty (ViewState data is responsible for maintaining the items).
Now the only way I can think of to get the SelectedIndex is to somehow get
the text that the DropDownList posted to the server and perform an IndexOf()
or FindByText().
My question is how do I manually get the text that a certain control posted
when in IsPostBack mode?
Is there a Collection somewhere of posted data?
Do controls expose raw posted data somewhere?
Cheers
Nathan
Nathan Baulch Guest
-
resize control inherited from System.Web.UI.Control in design mode
How I can resize control inherited from System.Web.UI.Control in design mode. Thanks a lot. -
Not IsPostBack
I have a problem. I have a function Load_Info where I am generating dymanic table. On a first load is it fine however after the refresh because it... -
Executing code that is part of a control after it gets posted back from the form in the users browser.
Hello dear .NET'rs, I have made a simple RememberingTextBox control which looks in the session for a session variable with the same name as the... -
[PHP] Text boxes posted to MySQL record that contain quotes
wow i've had this issue aswell only yesterday , like in my search page of the project i've just done i stored the search values of each option so... -
Text boxes posted to MySQL record that contain quotes
I know that using stripslashes will remove \ using php but I'm having trouble with posting quotation marks in a text record field. Anyone know how... -
Nathan Baulch #2
Re: Manually get the text that a certain control posted when in IsPostBack mode...
> My question is how do I manually get the text that a certain control
My solution was to subclass the DropDownList control and use the> posted when in IsPostBack mode?
> Is there a Collection somewhere of posted data?
> Do controls expose raw posted data somewhere?
LoadPostData method to save the postback data to a property. Here is the
code for anybody who is interested:
public class CustomDDL : DropDownList,IPostBackDataHandler
{
private string postedText;
private string text;
public string PostedText {
get {
return postedText;
}
}
public string Text {
set {
text = value;
}
}
public virtual bool LoadPostData(
string postDataKey,NameValueCollection values) {
postedText = values[postDataKey];
return false;
}
protected override void OnDataBinding(EventArgs e) {
base.OnDataBinding(e);
SelectedIndex = Items.IndexOf(Items.FindByText(text));
}
}
Nathan Baulch Guest



Reply With Quote

