Click here to Skip to main content
15,900,461 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Urgent WebService Pin
Member 144327816-Oct-09 3:24
Member 144327816-Oct-09 3:24 
QuestionIsCrossPagePostBack Pin
md_refay17-Aug-07 1:08
md_refay17-Aug-07 1:08 
AnswerRe: IsCrossPagePostBack Pin
Talal Sultan17-Aug-07 2:33
Talal Sultan17-Aug-07 2:33 
QuestionTimeouts after application running for a while Pin
Manime17-Aug-07 0:54
Manime17-Aug-07 0:54 
AnswerRe: Timeouts after application running for a while Pin
kubben17-Aug-07 1:49
kubben17-Aug-07 1:49 
GeneralRe: Timeouts after application running for a while Pin
Manime17-Aug-07 1:56
Manime17-Aug-07 1:56 
QuestionTrouble with Casini, Vista and HTTPS Pin
Tristan Rhodes17-Aug-07 0:37
Tristan Rhodes17-Aug-07 0:37 
QuestionUser Control Losing State? Pin
Dave Sexton17-Aug-07 0:36
Dave Sexton17-Aug-07 0:36 
I've created a web user control with a few properties that I want to assign to a different object during postback but it seems like the user control gets re-instantiated or something and passes back as null. What am I doing wrong? I've tried with a simpler user control and the same thing happens.

Here's the code I'm using. Hope it makes it clearer.

WebUserControl.ascx
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
<asp:button id="Button1" runat="server" text="Click" />

WebUserControl.ascx.cs
private string _Text;

public string Text // property to assign later
{
get { return _Text; }
set { _Text = value; }
}

public event EventHandler ValueChanged;

protected void OnValueChanged(EventArgs e)
{
if (ValueChanged != null)
{
ValueChanged(this, e);
}
}

protected void Button1_Click(object sender, System.EventArgs e)
{
Text = TextBox1.Text; // assign property value
OnValueChanged(e); // raise event
}

Then, after dropping the user control onto the web form...

Default.aspx

<uc1:webusercontrol id="WebUserControl1" runat="server" onvaluechanged="WebUserControl1_ValueChanged" />
<br />
<br />
<asp:button id="btnAssign" runat="server" onclick="btnAssign_Click" text="Assign Value" />

So far so good...
Default.aspx.cs

string _MyText; // want to assign to this

protected void WebUserControl1_ValueChanged(object sender, EventArgs e)
{

btnAssign.Text = WebUserControl1.Text; // This works
}

protected void btnAssign_Click(object sender, EventArgs e)
{
_MyText = WebUserControl1.Text; //This says WebUserControl1.Text = null
}

I'm sure it's something really stupid that I'm forgetting to do or maybe the way I've gone about it but it's got me stuck & I'd really appreciate someone telling me where I've missed it.

Thanks.
AnswerRe: User Control Losing State? Pin
Dave Sexton17-Aug-07 1:02
Dave Sexton17-Aug-07 1:02 
AnswerRe: User Control Losing State? Pin
Imran Khan Pathan17-Aug-07 3:25
Imran Khan Pathan17-Aug-07 3:25 
Questionproblem on checkboxlist control Pin
biswa4717-Aug-07 0:36
biswa4717-Aug-07 0:36 
AnswerRe: problem on checkboxlist control Pin
Michael Sync17-Aug-07 2:32
Michael Sync17-Aug-07 2:32 
QuestionIntegrated Security=True Pin
saravanan0517-Aug-07 0:35
saravanan0517-Aug-07 0:35 
AnswerRe: Integrated Security=True Pin
Vasudevan Deepak Kumar17-Aug-07 0:39
Vasudevan Deepak Kumar17-Aug-07 0:39 
QuestionTextbox time format....., Pin
Member 387988117-Aug-07 0:26
Member 387988117-Aug-07 0:26 
AnswerRe: Textbox time format....., Pin
sidbaruah17-Aug-07 0:42
sidbaruah17-Aug-07 0:42 
GeneralRe: Textbox time format....., Pin
Member 387988117-Aug-07 1:13
Member 387988117-Aug-07 1:13 
GeneralRe: Textbox time format....., Pin
sidbaruah17-Aug-07 1:34
sidbaruah17-Aug-07 1:34 
GeneralRe: Textbox time format....., Pin
Imran Khan Pathan17-Aug-07 1:35
Imran Khan Pathan17-Aug-07 1:35 
GeneralRe: Textbox time format....., Pin
Member 387988117-Aug-07 1:46
Member 387988117-Aug-07 1:46 
GeneralRe: Textbox time format....., Pin
Imran Khan Pathan17-Aug-07 2:59
Imran Khan Pathan17-Aug-07 2:59 
QuestionConnection string to access 2007 error Pin
samerh17-Aug-07 0:18
samerh17-Aug-07 0:18 
AnswerRe: Connection string to access 2007 error Pin
Vasudevan Deepak Kumar17-Aug-07 0:44
Vasudevan Deepak Kumar17-Aug-07 0:44 
GeneralRe: Connection string to access 2007 error Pin
samerh17-Aug-07 1:00
samerh17-Aug-07 1:00 
Questioninstalling a web appication Pin
Tomic17-Aug-07 0:04
Tomic17-Aug-07 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.