473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem with textbox

Hey

asp.net 2.0

I have a UserControl which contain many TextBoxes. When I from the webpage
(the webpage containing this UserControl) click on a button to start save
the text in the textBoxes, then nothing is saved....

I've debugged and discovered that the TextBox.Text = "", but I typed in a
value in that TextBox...

Here is some of the source of my UserControl:
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell Width="130px" CssClass="fieldname">First
name:</asp:TableCell>
<asp:TableCell Width="300px">
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>

This is the method I use to save the values in TextyBoxes:
It's in this method the error occur... txtFirstName.Text = "", but it should
for example be "helloworld"
public void SaveInfo(ProfileCommon profile)
{
profile.LastName = txtLastName.Text;
profile.FirstName = txtFirstName.Text;
profile.Website = txtWebsite.Text;
profile.Address.Street = txtStreet.Text;
profile.BirthDate = Convert.ToDateTime(txtBirthDate.Text);
}

The event handler of the button in the web page:
protected void btnSave_Click(object sender, EventArgs e)
{
this.Settings1.SaveInfo(Profile);
}

Any suggestions?

Jeff
Oct 10 '06 #1
4 1313


Are you exposing the "Profile" object ........ as a Property of the
UserControl?

code of hte usercontrol

private Profile m_profileInfo;

public Profile TheProfile()
get
{
this.PopulateProfile();
return this.m_profileInfo;
}

private void PopulateProfile()
{
m_profileInfo = new Profile();
m_profileInfo.FirstName = this.txtFirstName.Text;
m_profileInfo.LastName = this.txtLastName.Text;
}
.....................

Now, there is a web page using the userControl.
button1_click()

Profile profOne /* using antoher variable name to avoid ambiguity*/ =
myUserControl.Profile;
Response.Write (profOne.Firstname)

...............
Always remember that a UserControl is nothing but an object at its core. And
you exposed properties/methods on it like any other object.


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OX**************@TK2MSFTNGP04.phx.gbl...
Hey

asp.net 2.0

I have a UserControl which contain many TextBoxes. When I from the webpage
(the webpage containing this UserControl) click on a button to start save
the text in the textBoxes, then nothing is saved....

I've debugged and discovered that the TextBox.Text = "", but I typed in a
value in that TextBox...

Here is some of the source of my UserControl:
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell Width="130px" CssClass="fieldname">First
name:</asp:TableCell>
<asp:TableCell Width="300px">
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>

This is the method I use to save the values in TextyBoxes:
It's in this method the error occur... txtFirstName.Text = "", but it
should
for example be "helloworld"
public void SaveInfo(ProfileCommon profile)
{
profile.LastName = txtLastName.Text;
profile.FirstName = txtFirstName.Text;
profile.Website = txtWebsite.Text;
profile.Address.Street = txtStreet.Text;
profile.BirthDate = Convert.ToDateTime(txtBirthDate.Text);
}

The event handler of the button in the web page:
protected void btnSave_Click(object sender, EventArgs e)
{
this.Settings1.SaveInfo(Profile);
}

Any suggestions?

Jeff


Oct 10 '06 #2
No, as far as I know I'm not exposing the "Profile" object as a property in
the UserControl. The "Profile" object is in the webpage, and I'm just
sending the "Profile" object to the UserControl.

The error is because txtFirstName.Text has the value "", but it should got a
value.. I'm not sure this has something to do with the "Propfile" object...
but I'm a newbie, and I've been wrong before.... I have the same problem if
don't pass the "profile" object from the webpage to the UserControl.:

string fname = txtFirstName.Text.. txtFirstName.Text = ""... but I'm sure I
typed "helloworld"

Any suggestions?

Jeff
"sloan" <sl***@ipass.netwrote in message
news:O7**************@TK2MSFTNGP04.phx.gbl...
>

Are you exposing the "Profile" object ........ as a Property of the
UserControl?

code of hte usercontrol

private Profile m_profileInfo;

public Profile TheProfile()
get
{
this.PopulateProfile();
return this.m_profileInfo;
}

private void PopulateProfile()
{
m_profileInfo = new Profile();
m_profileInfo.FirstName = this.txtFirstName.Text;
m_profileInfo.LastName = this.txtLastName.Text;
}
....................

Now, there is a web page using the userControl.
button1_click()

Profile profOne /* using antoher variable name to avoid ambiguity*/ =
myUserControl.Profile;
Response.Write (profOne.Firstname)

..............
Always remember that a UserControl is nothing but an object at its core.
And
you exposed properties/methods on it like any other object.


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OX**************@TK2MSFTNGP04.phx.gbl...
>Hey

asp.net 2.0

I have a UserControl which contain many TextBoxes. When I from the
webpage
(the webpage containing this UserControl) click on a button to start save
the text in the textBoxes, then nothing is saved....

I've debugged and discovered that the TextBox.Text = "", but I typed in a
value in that TextBox...

Here is some of the source of my UserControl:
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell Width="130px" CssClass="fieldname">First
name:</asp:TableCell>
<asp:TableCell Width="300px">
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>

This is the method I use to save the values in TextyBoxes:
It's in this method the error occur... txtFirstName.Text = "", but it
should
>for example be "helloworld"
public void SaveInfo(ProfileCommon profile)
{
profile.LastName = txtLastName.Text;
profile.FirstName = txtFirstName.Text;
profile.Website = txtWebsite.Text;
profile.Address.Street = txtStreet.Text;
profile.BirthDate = Convert.ToDateTime(txtBirthDate.Text);
}

The event handler of the button in the web page:
protected void btnSave_Click(object sender, EventArgs e)
{
this.Settings1.SaveInfo(Profile);
}

Any suggestions?

Jeff



Oct 10 '06 #3
More info:

These are 2 event handlers from the web page containing the UserControl:
public partial class Network_Profile_Settings : AH.MyNetwork.UI.BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
this.Settings1.SetInfo(Profile);
}

protected void btnSave_Click(object sender, EventArgs e)
{
this.Settings1.SaveInfo();
}
}

These are the 2 methods in the UserControl (they are referenced from the web
page, see above):
public void SetInfo(ProfileCommon profile)
{
txtLastName.Text = profile.LastName;
txtWebsite.Text = profile.Website;
txtStreet.Text = profile.Address.Street;
txtBirthDate.Text = profile.BirthDate.ToString();
}

public void SaveInfo()
{
string fname = txtFirstName.Text;
}

This is the markup of the button I use to save the text entered
<asp:Button runat="server" Text="Save" OnClick="btnSave_Click"></asp:Button>

But the strange is that when clicking on this button, the SetInfo method is
executed before SaveInfo....

Why are SetInfo executed before SaveInfo when I click the button?


"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OX**************@TK2MSFTNGP04.phx.gbl...
Hey

asp.net 2.0

I have a UserControl which contain many TextBoxes. When I from the webpage
(the webpage containing this UserControl) click on a button to start save
the text in the textBoxes, then nothing is saved....

I've debugged and discovered that the TextBox.Text = "", but I typed in a
value in that TextBox...

Here is some of the source of my UserControl:
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell Width="130px" CssClass="fieldname">First
name:</asp:TableCell>
<asp:TableCell Width="300px">
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>

This is the method I use to save the values in TextyBoxes:
It's in this method the error occur... txtFirstName.Text = "", but it
should for example be "helloworld"
public void SaveInfo(ProfileCommon profile)
{
profile.LastName = txtLastName.Text;
profile.FirstName = txtFirstName.Text;
profile.Website = txtWebsite.Text;
profile.Address.Street = txtStreet.Text;
profile.BirthDate = Convert.ToDateTime(txtBirthDate.Text);
}

The event handler of the button in the web page:
protected void btnSave_Click(object sender, EventArgs e)
{
this.Settings1.SaveInfo(Profile);
}

Any suggestions?

Jeff

Oct 11 '06 #4
Solved, I've forgotten to test if it's postback

protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostback) {
this.Settings1.SetInfo(Profile);
}
}

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OX**************@TK2MSFTNGP04.phx.gbl...
Hey

asp.net 2.0

I have a UserControl which contain many TextBoxes. When I from the webpage
(the webpage containing this UserControl) click on a button to start save
the text in the textBoxes, then nothing is saved....

I've debugged and discovered that the TextBox.Text = "", but I typed in a
value in that TextBox...

Here is some of the source of my UserControl:
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell Width="130px" CssClass="fieldname">First
name:</asp:TableCell>
<asp:TableCell Width="300px">
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>

This is the method I use to save the values in TextyBoxes:
It's in this method the error occur... txtFirstName.Text = "", but it
should for example be "helloworld"
public void SaveInfo(ProfileCommon profile)
{
profile.LastName = txtLastName.Text;
profile.FirstName = txtFirstName.Text;
profile.Website = txtWebsite.Text;
profile.Address.Street = txtStreet.Text;
profile.BirthDate = Convert.ToDateTime(txtBirthDate.Text);
}

The event handler of the button in the web page:
protected void btnSave_Click(object sender, EventArgs e)
{
this.Settings1.SaveInfo(Profile);
}

Any suggestions?

Jeff

Oct 11 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Peter Proost | last post by:
Hi group, I've got what seems a simple problem, but I can't find the solution. I've got a textbox and a handheld scanner to scan barcodes, the scanner just generates keypresses like a keyboard...
4
by: Rod Gill | last post by:
Hi, I have a form that when opened in the designer appears of the screen. The form selector can't be dragged (or resized) and if I scroll right and down to centralise it the form simply jumps...
30
by: dbuchanan | last post by:
ComboBox databindng Problem == How the ComboBox is setup and used: My comboBox is populated by a lookup table. The ValueMember is the lookup table's Id and the DisplayMember is the text from a...
12
by: Joel Byrd | last post by:
I'm having a little problem with using type-ahead functionality for an auto-suggest box. Sometimes, when I start to type something and the type-ahead shows up, the AJAX will send a request query...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
2
by: DC | last post by:
The Code <%@ import namespace="System" %> <%@ import namespace="System.Web" %> <%@ import namespace="System.Web.UI" %> <%@ import namespace="System.Web.UI.HtmlControls" %> <%@ import...
1
by: Werner Schmidt | last post by:
Dear group, I have a very strange behaviour: In a loop there are several TextBoxes initialized: TextBox objTextBox = null; // one declaration for-loop // multiple initialisations
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
4
by: pankajsingh5k | last post by:
Hi guys, These question is for all the experts... Please help me before my brain explodes The problem is again with the formview control.. I have a formview and i have to use it that...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.