Saturday, March 31, 2012

Text box losing most recent Text value

It's me and my registration page again. I have a subroutine that calculates
the total fees the registrant will incur and puts it in a textbox (not a
label because it has to be passed to another page).

txtTotalFees.Text = Format(dblTotalFees, "Currency")

The subroutine works fine IF I call it from PageLoad, or I assign it to a
button for recalculating the total fees, or the user clicks the Reset
button, or if they click a control that has AutoPostback set to true.
Basically anything that loads or postbacks the page.

BUT...When it comes time to submit the page and go to the next page I have
this code:

If IsValid Then
CalcFees() 'recalcs fees and updates textbox
Server.Transfer("Confirmation.aspx", True)
End If

When the user gets to the next page I put the total fees in another textbox.
EXCEPT it isn't updated to most recent total. I know because I can comment
out the "Server.Transfer" so that it stays at the registration page AND THE
CORRECT TOTAL IS DISPLAYED!?!?!

What is it about the Server.Transfer that "forgets" what the value of the
textbox should be?

Ken "BiggMakk" McCroryHi Ken

Try this:
Server.Transfer("Confirmation.aspx", True)
This sets the parameter preserveForm to true, hence preserving any
variables still available.

You can then retrieve the value from your previous page on the
Confirmation.aspx page by using Request.Form("totalFees")

Hope that helps :)
sze
Thanks for the try but I am already using the True to preserve variables.
(See original post. It's there.)

Ken "BiggMakk" McCrory

"sze" <szeying.tan@.gmail.com> wrote in message
news:1110401185.776188.29550@.o13g2000cwo.googlegro ups.com...
> Hi Ken
> Try this:
> Server.Transfer("Confirmation.aspx", True)
> This sets the parameter preserveForm to true, hence preserving any
> variables still available.
> You can then retrieve the value from your previous page on the
> Confirmation.aspx page by using Request.Form("totalFees")
> Hope that helps :)
> sze
Ah, sorry. I didn't notice it in your code at first glance.

Here's a helpful page from MSDN about preserving state between pages.
http://msdn.microsoft.com/library/d...etweenPages.asp

Hope that helps.
I solved this by using SmartNavigation and turning on Autopostback for every
control that can affect the total fees. Before someone says SmartNav doesn't
work in browsers other than IE, you're right. Someone else in a different
post of mine pointed out Smart Scroller by Strength Technologies at this web
site:

http://www.strengthtechnologies.com...l/Download.aspx

It works even in Firefox.

Now the Total fees gets updated before the user hits the Submit button and
the correct value gets passed to the next page. It also removes the need for
the manual "Recalculate Fees" button that I had on the page.
--
Ken "BiggMakk" McCrory

"Ken McCrory" <klm355t@.removefornospammers.smsu.edu> wrote in message
news:OjfvdfOJFHA.688@.TK2MSFTNGP10.phx.gbl...
> It's me and my registration page again. I have a subroutine that
> calculates the total fees the registrant will incur and puts it in a
> textbox (not a label because it has to be passed to another page).
> txtTotalFees.Text = Format(dblTotalFees, "Currency")
> The subroutine works fine IF I call it from PageLoad, or I assign it to a
> button for recalculating the total fees, or the user clicks the Reset
> button, or if they click a control that has AutoPostback set to true.
> Basically anything that loads or postbacks the page.
> BUT...When it comes time to submit the page and go to the next page I have
> this code:
> If IsValid Then
> CalcFees() 'recalcs fees and updates textbox
> Server.Transfer("Confirmation.aspx", True)
> End If
> When the user gets to the next page I put the total fees in another
> textbox. EXCEPT it isn't updated to most recent total. I know because I
> can comment out the "Server.Transfer" so that it stays at the registration
> page AND THE CORRECT TOTAL IS DISPLAYED!?!?!
> What is it about the Server.Transfer that "forgets" what the value of the
> textbox should be?
> Ken "BiggMakk" McCrory
Yeah Ken the control works with FireFox and I.E!!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Text Box Loses Value On Page Load

Hi Folks...this is a wierd issue I've noticed and wanted to know of a) anyon
e
else has noticed this and b) if so, why does it happen.
On page load, I have a text box named me.txtMemberName. I enter data into
this field then submit the page. If I check the value of
me.txtMemberName.text during the page load event, it is an empty string. Now
,
if I check this again in a later event, the value of .text has the correct
inforamation in it. This is causing me grief b/c, since this is a required
field, Page.IsValid is failing on page load. Any thoughts?
Thanks!
ClayFirst of all, I am assuming you have EnableViewState=True for this Control,
as well as for the Page. Second, can you post your Page.Load procedure so we
can see exactly what you do there and how you do it? This may help me and
others help you solve your problem. Thanks.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Clayton Hoyt" <ClaytonHoyt@.discussions.microsoft.com> wrote in message
news:1D931693-325B-4116-901F-3D09CF24FE8C@.microsoft.com...
> Hi Folks...this is a wierd issue I've noticed and wanted to know of a)
> anyone
> else has noticed this and b) if so, why does it happen.
> On page load, I have a text box named me.txtMemberName. I enter data into
> this field then submit the page. If I check the value of
> me.txtMemberName.text during the page load event, it is an empty string.
> Now,
> if I check this again in a later event, the value of .text has the correct
> inforamation in it. This is causing me grief b/c, since this is a required
> field, Page.IsValid is failing on page load. Any thoughts?
> Thanks!
> Clay

Text box on same line as Radio Buttons

Using ASP.Net1.0
How can I get "Type of degree" and the following text box on the same line
as the radio buttons for "CollegeCompleted"?
I have tried <div style="float:left">, which works well for me in other
areas, but not in this case.
<HR>
College Name <span style="margin-left:162px;">
City/State <br>
<asp:TextBox id="College" columns = "35" runat=server/>
<asp:TextBox id="CollegeCity" columns = "35" runat=server/>
<br>Last Year Completed
<asp:RadioButtonList id="CollegeCompleted" RepeatDirection="horizontal"
Runat=server>
<asp:ListItem><font size="2"> 1</asp:ListItem>
<asp:ListItem><font size="2">2</asp:ListItem>
<asp:ListItem><font size="2">3</asp:ListItem>
<asp:ListItem><font size="2">4</asp:ListItem>
<asp:ListItem><font size="2">5</asp:ListItem>
</asp:RadioButtonList>
Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
<HR>On Aug 17, 6:40 pm, "dancer" <dan...@.microsoft.com> wrote:
> Using ASP.Net1.0
> How can I get "Type of degree" and the following text box on the same lin
e
> as the radio buttons for "CollegeCompleted"?
> I have tried <div style="float:left">, which works well for me in other
> areas, but not in this case.
>

> College Name <span style="margin-left:162px;">
> City/State <br>
> <asp:TextBox id="College" columns = "35" runat=server/>
> <asp:TextBox id="CollegeCity" columns = "35" runat=server/>
> <br>Last Year Completed
> <asp:RadioButtonList id="CollegeCompleted" RepeatDirection="horizontal"
> Runat=server>
> <asp:ListItem><font size="2"> 1</asp:ListItem>
> <asp:ListItem><font size="2">2</asp:ListItem>
> <asp:ListItem><font size="2">3</asp:ListItem>
> <asp:ListItem><font size="2">4</asp:ListItem>
> <asp:ListItem><font size="2">5</asp:ListItem>
> </asp:RadioButtonList>
> Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
>

Hi dancer,
You should add RepeatLayout="Flow" to RadioButtonList:
<asp:RadioButtonList id="CollegeCompleted"
RepeatDirection="horizontal"
Runat=server RepeatLayout="Flow">
<asp:ListItem><font size="2"> 1</asp:ListItem>
<asp:ListItem><font size="2">2</asp:ListItem>
<asp:ListItem><font size="2">3</asp:ListItem>
<asp:ListItem><font size="2">4</asp:ListItem>
<asp:ListItem><font size="2">5</asp:ListItem>
</asp:RadioButtonList>
Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
Regards,
Alexander Kleshchevnikov
MCP
www.klalex.com
That worked well. THANK YOU.
"seigo" <seigo.ua@.gmail.com> wrote in message
news:1187365869.355627.265430@.w3g2000hsg.googlegroups.com...
> On Aug 17, 6:40 pm, "dancer" <dan...@.microsoft.com> wrote:
> Hi dancer,
> You should add RepeatLayout="Flow" to RadioButtonList:
> <asp:RadioButtonList id="CollegeCompleted"
> RepeatDirection="horizontal"
> Runat=server RepeatLayout="Flow">
>
> <asp:ListItem><font size="2"> 1</asp:ListItem>
>
> <asp:ListItem><font size="2">2</asp:ListItem>
>
> <asp:ListItem><font size="2">3</asp:ListItem>
>
> <asp:ListItem><font size="2">4</asp:ListItem>
>
> <asp:ListItem><font size="2">5</asp:ListItem>
>
> </asp:RadioButtonList>
>
> Type of Degree: <asp:TextBox id="DegreeCollege" runat=server/>
> Regards,
> Alexander Kleshchevnikov
> MCP
> www.klalex.com
>

Text Box Problem

Hello,
I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.
I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.
I have no idea why do I get this error.
The form with Runat="server" is in the master page.
Anyway, can someone tell me how can I figure what is going on?
Thanks,
MiguelHere is my code.
I am adding and creating all controls at runtime in my pages.
---
Base.master:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html>
Base.master.vb:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init
Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)
Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)
End Sub
MyPage.aspx:
<%@. Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default"
%>
MyPage.aspx.vb:
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init
Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)
End Sub
Class Contact in Namespace By27.Web.UI:
Namespace Web.UI.Form
' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm
runat=server></{0}:ContactForm>")> _
Public Class Contact
Inherits WebControl
Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub
<Bindable(True), Category("Appearance"), DefaultValue(""),
Localizable(True)> Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property
Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub
End Class
---
Thanks,
Miguel
shapper wrote:
> Hello,
> I have a master page where my form has the Runat="server".
> The master page as a control place holder, named "cphContent".
> Then in a page which inherits from the master page I added a custom
> control which I created.
> This custom control is added to "cphContent" at runtime.
> The custom control creates and adds 2 textboxes using
> CreateChildControls.
> I am getting an error:
> System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
> type 'TextBox' must be placed inside a form tag with runat=server.
> I have no idea why do I get this error.
> The form with Runat="server" is in the master page.
> Anyway, can someone tell me how can I figure what is going on?
> Thanks,
> Miguel
This is a bug of Visual Studio. A problem is that in content page you don't
have form
"shapper" <mdmoura@.gmail.com> wrote in message
news:1163016480.466822.19390@.m7g2000cwm.googlegroups.com...
> Hello,
> I have a master page where my form has the Runat="server".
> The master page as a control place holder, named "cphContent".
> Then in a page which inherits from the master page I added a custom
> control which I created.
> This custom control is added to "cphContent" at runtime.
> The custom control creates and adds 2 textboxes using
> CreateChildControls.
> I am getting an error:
> System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
> type 'TextBox' must be placed inside a form tag with runat=server.
> I have no idea why do I get this error.
> The form with Runat="server" is in the master page.
> Anyway, can someone tell me how can I figure what is going on?
> Thanks,
> Miguel
>

Text Box Problem

Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
MiguelHere is my code.

I am adding and creating all controls at runtime in my pages.

----------------------

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html>

Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

MyPage.aspx:

<%@. Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default"
%>

MyPage.aspx.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
Handles Me.Init

Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)

End Sub

Class Contact in Namespace By27.Web.UI:

Namespace Web.UI.Form

' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm
runat=server></{0}:ContactForm>")_
Public Class Contact
Inherits WebControl

Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As
System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub

<Bindable(True), Category("Appearance"), DefaultValue(""),
Localizable(True)Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property

Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

----------------------

Thanks,

Miguel

shapper wrote:

Quote:

Originally Posted by

Hello,
>
I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.
>
I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.
>
I have no idea why do I get this error.
The form with Runat="server" is in the master page.
>
Anyway, can someone tell me how can I figure what is going on?
>
Thanks,
Miguel


This is a bug of Visual Studio. A problem is that in content page you don't
have form

"shapper" <mdmoura@.gmail.comwrote in message
news:1163016480.466822.19390@.m7g2000cwm.googlegrou ps.com...

Quote:

Originally Posted by

Hello,
>
I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom
control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using
CreateChildControls.
>
I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of
type 'TextBox' must be placed inside a form tag with runat=server.
>
I have no idea why do I get this error.
The form with Runat="server" is in the master page.
>
Anyway, can someone tell me how can I figure what is going on?
>
Thanks,
Miguel
>
>

Text Box Problem

Hello,

I have a master page where my form has the Runat="server".
The master page as a control place holder, named "cphContent".
Then in a page which inherits from the master page I added a custom control which I created.
This custom control is added to "cphContent" at runtime.
The custom control creates and adds 2 textboxes using CreateChildControls.

I am getting an error:
System.Web.HttpException: Control 'ctl00_cphContent_by27cf_tbName' of type 'TextBox' must be placed inside a form tag with runat=server.

I have no idea why do I get this error.
The form with Runat="server" is in the master page.

Anyway, can someone tell me how can I figure what is going on?

Thanks,
MiguelYou may need to show some code of how do you set up the Content page.

Here is my code.

I am adding and creating all controls at runtime in my pages.

----------------------

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html
Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

MyPage.aspx:

<%@. Page Language="VB" CodeFile="Default.aspx.vb" Inherits="_Default" %>

MyPage.aspx.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init

Dim by27fContactForm As New By27.Web.UI.Form.Contact
AddHandler by27fContactForm.Init, AddressOf by27fContactForm_Init
pContacts.Controls.Add(by27fContactForm)

End Sub

Class Contact in Namespace By27.Web.UI:

Namespace Web.UI.Form

' Content
<DefaultProperty("Text"), ToolboxData("<{0}:ContactForm runat=server></{0}:ContactForm>")> _
Public Class Contact
Inherits WebControl

Dim by27cf_tbName As New WebControls.TextBox
Private Sub by27cf_tbName_Init(ByVal sender As Object, ByVal e As System.EventArgs)
With by27cf_tbName
.CssClass = Me.TextBoxCssClass
.ID = "by27cf_tbName"
.Width = Unit.Percentage(100)
End With
End Sub

<Bindable(True), Category("Appearance"), DefaultValue(""), Localizable(True)> Property TextBoxCssClass() As String
Get
If CStr(ViewState("TextBoxCssClass")) Is Nothing Then
Return String.Empty
Else
Return CStr(ViewState("TextBoxCssClass"))
End If
End Get
Set(ByVal Value As String)
ViewState("TextBoxCssClass") = Value
End Set
End Property

Protected Overrides Sub CreateChildControls()
AddHandler by27cf_tbName.Init, AddressOf by27cf_tbName_Init
MyBase.Controls.Add(by27cf_tbName)
' Create child controls
MyBase.CreateChildControls()
Me.ChildControlsCreated = True
End Sub

End Class

----------------------

Thanks,

Miguel


The controls are not being added between the form tags. Add a placeholder to the masterpage and add your controls (panel/contentholder) to that, instead of the page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server">
<asp:PlaceHolder id="ControlHolder" runat="server"/>
</form>
</body>
</html>


In this line

pContent.Controls.Add(cphContent)

What and/or where is "pContent"? It isn't entirely clear where you're getting it from.


It should be pContainer and not pContent.

It was a mistake when coping it to here. I just copied parts of the code to give an idea


shapper:

Base.master:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="fBase" runat="server"></form>
</body>
</html
Base.master.vb:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init

Dim pContainer As New Panel
AddHandler pContainer.Init, AddressOf pContainer_Init
Me.Controls.Add(pContainer)

Dim cphContent As New ContentPlaceHolder
AddHandler cphContent.Init, AddressOf cphContent_Init
pContent.Controls.Add(cphContent)

End Sub

In the Page_Init above, you are adding a Panel to thepage, but not to theform. Therefore, cphContent is not in the form. And when you add the custom control to cphContent, then obviously that's not in the form either.

Text box reading old value

Hi i am trying to create a simple page that would allow users to edit there infromation that is stored on them,

It loads the information from the database fine and puts it into the textbox's but then on the "update" button it doesnt get the changed values

e.g

if the textbox was set on the page load to "bren" and then i changed it on the page to be "Hello" when i execute the onlclick function of the button it still reads as "bren"

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.Odbc;public partialclass user_userDetails : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {if (!HttpContext.Current.User.Identity.Name.Contains(ConfigurationManager.AppSettings["siteGSTPrefix"])) {string userGuid = HttpContext.Current.User.Identity.Name; OdbcConnection detailsCon = sqlconnect.Connect(); OdbcCommand detailsCom =new OdbcCommand("SELECT tbl_usr.Username,tbl_usr_info.first_name,tbl_usr_info.second_name,tbl_usr_info.address_line_1,tbl_usr_info.address_line_2,tbl_usr_info.address_line_3,tbl_usr_info.post_code,tbl_usr_info.home_phone,tbl_usr_info.work_phone,tbl_usr_info.email_addy FROM tbl_usr INNER JOIN tbl_usr_info ON tbl_usr.usr_guid = tbl_usr_info.usr_guid WHERE tbl_usr.usr_guid='" + userGuid +"'", detailsCon); OdbcDataReader detRead = detailsCom.ExecuteReader();while (detRead.Read()) { userNote.Text ="Your Password is not displayed for security!"; userName.Text = detRead["Username"].ToString().Replace("#@dotnet.itags.org.","'"); fName.Text = detRead["first_name"].ToString().Replace("#@dotnet.itags.org.","'"); sName.Text = detRead["second_name"].ToString().Replace("#@dotnet.itags.org.","'"); aD1.Text = detRead["address_line_1"].ToString().Replace("#@dotnet.itags.org.","'"); aD2.Text = detRead["address_line_2"].ToString().Replace("#@dotnet.itags.org.","'"); aD3.Text = detRead["address_line_3"].ToString().Replace("#@dotnet.itags.org.","'"); pCode.Text = detRead["post_code"].ToString().Replace("#@dotnet.itags.org.","'"); hPhone.Text = detRead["home_phone"].ToString().Replace("#@dotnet.itags.org.","'"); wPhone.Text = detRead["work_phone"].ToString().Replace("#@dotnet.itags.org.","'"); eAddy.Text = detRead["email_addy"].ToString().Replace("#@dotnet.itags.org.","'"); } detRead.Close(); detailsCon.Close(); }else { Response.Redirect(FormsAuthentication.LoginUrl); } }protected void update_click(object sender, EventArgs e) {string userGuid = HttpContext.Current.User.Identity.Name;string passSettings =string.Empty; Response.Clear();if(userPass.Text.ToString() !="" && userPass.Text.ToString() !=null) { passSettings =" , tbl_usr.Password = '" + userPass.Text.ToString().Replace("'","#@dotnet.itags.org.") +"'"; } OdbcConnection detCon = sqlconnect.Connect(); OdbcCommand upCom =new OdbcCommand("UPDATE tbl_usr SET tbl_usr.Username = '" + userName.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' " + passSettings +" WHERE tbl_usr.usr_guid = '" + userGuid +"'", detCon); upCom.ExecuteNonQuery(); OdbcCommand upComInfo =new OdbcCommand("UPDATE tbl_usr_info SET tbl_usr_info.first_name = '" + fName.Text.Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.second_name = '" + sName.Text.Replace("'","#@dotnet.itags.org.").Trim() +"' , tbl_usr_info.address_line_1 = '" + aD1.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.address_line_2 = '" + aD2.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.address_line_3 = '" + aD3.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.post_code = '" + pCode.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.work_phone = '" + wPhone.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.home_phone = '" + hPhone.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' , tbl_usr_info.email_addy = '" + eAddy.Text.ToString().Replace("'","#@dotnet.itags.org.") +"' WHERE tbl_usr_info.usr_guid = '" + userGuid +"'", detCon); upComInfo.ExecuteNonQuery(); userNote.Text ="Your details have been updated"; }}


Thanks for your help in advance

Dan

your update_click is happening after the page_load. try changing the code you have in page_load to page_prerender and see if you are good to go.


i have treid to user it with IsPostBack but it doesnt work,

i didnt think that Page_load was re run when u clicked on a button and ran the function

Dan


Fixed it now thanks changed it to a !IsPostBack and it now works thanks