By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,669 Members | 2,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,669 IT Pros & Developers. It's quick & easy.

problem with WebControls.TextBox

P: n/a
Howdy,

I'm new to this .net stuff and really have little to no training. Im trying
to create a new page for a web form, so i have been pretty much jsut coping
code. I having some issue with some textboxes not updating when i a hit
save.

for example I have this code in my aspx.cs file:

declared:
protected System.Web.UI.WebControls.TextBox txtFullName;

populated:
txtFullName.Text = oRDI.fullName;

this code works. When the page loads the fields have the correct info. The
aspx code for this field looks like this:

<tr>
<td style="WIDTH: 140px"><asp:label id="lblFullName" runat="server"
width="109px">Full Name:</asp:label></td>
<td style="WIDTH: 192px" colSpan="3"><asp:textbox id="txtFullName"
runat="server" width="544px" maxlength="32"></asp:textbox></td>
</tr>

When i hit the save button with this code:
<td><asp:imagebutton id="ibtnSave" runat="server"
imageurl="Images\btnSave.gif"
causesvalidation="False"></asp:imagebutton></td>

I assumed that the i accessed txtFullName from teh cs code it woudl be
updated with whatever i entered in the field, but it just comes up with the
same data that it was populated with.

What step am i missing? I have looked at teh other pages in my system to
see how they work, but i dont see any differences. I setting am i missing.

the form code looks like this:
<body ms_positioning="GridLayout">
<form id="ReportDetails" method="post" encType="multipart/form-data"
runat="server">
<table cellSpacing="0" cellPadding="0" width="760" border="0">

One quick note, when i get the value of the field using the Request.Params i
get the latest value. I could use this, but what the point of this fun
architecture then. btw, did i mention that i was new to this stuff : )

Thank You,
rodrigo
ro*************@dfps.state.tx.us
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jax
Do you initialize the text in the textbox to start with

E.G: Say in the Form_Load even

txtFullName.Text = ""

because if you have you want to change it to this instead

if(IsPostBack!=true

txtFullName.Text = ""
Nov 16 '05 #2

P: n/a
cs file:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.OracleClient;
using PRS.DocumentManager;

namespace PRS.UIDocumentManager
{
/// <summary>
/// Summary description for DocumentDetails.
/// </summary>
public class ReportDetails : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Table tblParamters;

protected System.Web.UI.WebControls.DropDownList ddlEmailOptions;
protected System.Web.UI.WebControls.Image imgLogo;
protected System.Web.UI.WebControls.ImageButton ibtnAdd;
protected System.Web.UI.WebControls.ImageButton ibtnCancel;
protected System.Web.UI.WebControls.ImageButton ibtnEdit;
protected System.Web.UI.WebControls.ImageButton ibtnDelete;
protected System.Web.UI.WebControls.ImageButton ibtnSave;
protected System.Web.UI.WebControls.ImageButton ibtnBack;

protected System.Web.UI.WebControls.Label lblError;
protected System.Web.UI.WebControls.Label lblDebugMsg;
protected System.Web.UI.WebControls.Label lblDocumentTypeList;
protected System.Web.UI.WebControls.Label lblFilter;
protected System.Web.UI.WebControls.Label lblReloadInfo;

protected System.Web.UI.WebControls.Label lblReportName;
protected System.Web.UI.WebControls.Label lblReportVersion;
protected System.Web.UI.WebControls.Label lblReportDetails;
protected System.Web.UI.WebControls.Label lblName;
protected System.Web.UI.WebControls.TextBox txtName;
protected System.Web.UI.WebControls.Label lblVersion;
protected System.Web.UI.WebControls.TextBox txtVersion;
protected System.Web.UI.WebControls.Label lblFullName;
protected System.Web.UI.WebControls.TextBox txtFullName;
protected System.Web.UI.WebControls.Label lblTemplateName;
protected System.Web.UI.WebControls.TextBox txtTemplateName;
protected System.Web.UI.WebControls.Label lblOrientation;
protected System.Web.UI.WebControls.TextBox txtOrientation;
protected System.Web.UI.WebControls.Label lblType;
protected System.Web.UI.WebControls.TextBox txtType;
protected System.Web.UI.WebControls.Label lblRetainage;
protected System.Web.UI.WebControls.TextBox txtRetainage;
protected System.Web.UI.WebControls.Label lblEmailOptions;
protected System.Web.UI.WebControls.TextBox txtEmailOptions;
protected System.Web.UI.WebControls.Label lblTitle;
protected System.Web.UI.WebControls.Label lblBackLink;
private void Page_Load(object sender, System.EventArgs e)
{
ReportDetailInfo oRDI;
DataSet oDS;
TableRow trRow;

ManagePageButtons(true,true,true, true, true);

String reportName = Request.QueryString["ID"];
String reportVersion = Request.QueryString["version"];

MetaDataAccessor oDataAccess = new MetaDataAccessor();
oRDI = oDataAccess.GetReportDetail( reportName , reportVersion );

lblReportName.Text = oRDI.name;
lblReportVersion.Text = oRDI.version;
txtName.Text = oRDI.name;
txtVersion.Text = oRDI.version;
txtFullName.Text = oRDI.fullName;
txtTemplateName.Text = oRDI.template;
txtOrientation.Text = oRDI.orientation;
txtType.Text = oRDI.type;
txtRetainage.Text = oRDI.retainage.ToString();
txtEmailOptions.Text = oRDI.emailOptions;

RegisterHiddenField("hdnTimeStamp",oRDI.TimeStamp. ToString());

oDataAccess = new MetaDataAccessor();
oDS = oDataAccess.GetReportParameters( reportName , reportVersion );
DataView dv = new DataView(oDS.Tables[0]);
DataTable newDt = oDS.Tables[0].Clone();
for (int i=0;i<dv.Count;i++)
{
newDt.ImportRow(dv[i].Row);
}
DataSet oDataSet = new DataSet();
oDataSet.Tables.Add(newDt);

if (oDataSet != null)
{
#region Building Table Headers
// Build the table headings
trRow = new TableRow();
tblParamters.Rows.Add(trRow);

TableCell tcCellHead = new TableCell();
tcCellHead.Text="Sequence";
tcCellHead.CssClass="THlist";
tcCellHead.Wrap=true;
tcCellHead.HorizontalAlign=HorizontalAlign.Center;
trRow.Cells.Add(tcCellHead);

tcCellHead = new TableCell();
tcCellHead.Text="Name";
tcCellHead.CssClass="THlist";
tcCellHead.Wrap=true;
tcCellHead.HorizontalAlign=HorizontalAlign.Center;
trRow.Cells.Add(tcCellHead);

tcCellHead = new TableCell();
tcCellHead.Text="Length";
tcCellHead.CssClass="THlist";
tcCellHead.Wrap=true;
tcCellHead.HorizontalAlign=HorizontalAlign.Center;
trRow.Cells.Add(tcCellHead);

tcCellHead = new TableCell();
tcCellHead.Text="Type";
tcCellHead.CssClass="THlist";
tcCellHead.Wrap=true;
tcCellHead.HorizontalAlign=HorizontalAlign.Center;
trRow.Cells.Add(tcCellHead);

#endregion

#region Building Table Items list
// Display the available templates
int RowCount=0;
foreach(DataRow drRow in oDataSet.Tables[0].Rows)
{
++RowCount;
trRow = new TableRow();
tblParamters.Rows.Add(trRow);

// Populate Data
// Catalog link
TableCell tcData = new TableCell();
tcData.HorizontalAlign =
System.Web.UI.WebControls.HorizontalAlign.Left;
if ((RowCount%2)==0)
tcData.CssClass = "altcolor";
tcData.Wrap = true;
tcData.Text = drRow["NBR_RPT_PARM_SEQ"].ToString();
trRow.Cells.Add(tcData);

// display name
tcData = new TableCell();
tcData.HorizontalAlign =
System.Web.UI.WebControls.HorizontalAlign.Left;
if ((RowCount%2)==0)
tcData.CssClass = "altcolor";
tcData.Wrap = true;
tcData.Text = drRow["NM_RPT_PARM_NAME"].ToString();
trRow.Cells.Add(tcData);

tcData = new TableCell();
tcData.HorizontalAlign =
System.Web.UI.WebControls.HorizontalAlign.Left;
if ((RowCount%2)==0)
tcData.CssClass = "altcolor";
tcData.Wrap = true;
tcData.Text = drRow["NBR_RPT_PARM_LENGTH"].ToString();
trRow.Cells.Add(tcData);

tcData = new TableCell();
tcData.HorizontalAlign =
System.Web.UI.WebControls.HorizontalAlign.Left;
if ((RowCount%2)==0)
tcData.CssClass = "altcolor";
tcData.Wrap = true;
tcData.Text = drRow["TXT_RPT_PARM_TYPE"].ToString();
trRow.Cells.Add(tcData);

}
#endregion

}
}

private void ReportErrMessage (Exception ex)
{
StringBuilder sb = new StringBuilder();

sb.Append("<p>" + ex.ToString());
Exception iEx = ex.InnerException;
while (iEx != null)
{
sb.Append("<p>" + iEx.ToString());
iEx = iEx.InnerException;
}
sb.Append("<P>" + ex.StackTrace);
lblDebugMsg.Text = sb.ToString().Replace("\n", "<p>");
}

private void ManagePageButtons( bool CancelBtn, bool AddBtn, bool
EditBtn, bool DeleteBtn, bool SaveBtn)
{
ibtnCancel.Visible = CancelBtn;
ibtnAdd.Visible = AddBtn;
ibtnEdit.Visible = EditBtn;
ibtnDelete.Visible = DeleteBtn;
ibtnSave.Visible = SaveBtn;
}

private void ManageTypeBoxes(bool MakeEditable)
{

}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ibtnBack.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnBack _Click);
this.ibtnCancel.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnCanc el_Click);
this.ibtnAdd.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnAdd_ Click);
this.ibtnEdit.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnEdit _Click);
this.ibtnDelete.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnDele te_Click);
this.ibtnSave.Click += new
System.Web.UI.ImageClickEventHandler(this.ibtnSave _Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void ibtnAdd_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Console.WriteLine("ADD");
}
private void ibtnSave_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
MetaDataAccessor oDataAccess = new MetaDataAccessor();

ReportDetailInfo reportDetailInfo = new ReportDetailInfo();

reportDetailInfo.name = lblReportName.Text;
reportDetailInfo.version = lblReportVersion.Text;
reportDetailInfo.name = txtName.Text;
reportDetailInfo.version = txtVersion.Text;
reportDetailInfo.fullName = txtFullName.Text;
reportDetailInfo.template = txtTemplateName.Text;
reportDetailInfo.orientation = txtOrientation.Text;
reportDetailInfo.type = txtType.Text;
reportDetailInfo.retainage = int.Parse( txtRetainage.Text );
reportDetailInfo.emailOptions = txtEmailOptions.Text;
reportDetailInfo.TimeStamp =
OracleDateTime.Parse(Request.Params["hdnTimeStamp"]);

//oDataAccess.UpdateReportDetails( reportDetailInfo );

}

private void ibtnEdit_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Console.WriteLine("EDIT");
}

private void ibtnDelete_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Console.WriteLine("delete");
}

private void ibtnCancel_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Console.WriteLine("cancel");
}

private void ibtnBack_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect(lblBackLink.Text);
}

}
}
-----------------------------------------
aspx:

<%@ Page language="c#" Codebehind="ReportDetails.aspx.cs"
AutoEventWireup="false" Inherits="PRS.UIDocumentManager.ReportDetails" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Report Details</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="css/impact.css" type="text/css" rel="stylesheet">
</HEAD>
<body ms_positioning="GridLayout">
<form id="ReportDetails" method="post" encType="multipart/form-data"
runat="server">
<table cellSpacing="0" cellPadding="0" width="760" border="0">
<tr>
<td>
<table class="TableBorderExpand" id="MainTable" cellSpacing="0"
cellPadding="3" width="100%"
border="0">
<tr>
<td class="THExpand">
<p><asp:image id="imgLogo" runat="server"
imageurl="Images\prs_seal.gif"></asp:image><asp:label id="lblTitle"
runat="server" cssclass="PageTitle">Report Details</asp:label></p>
</td>
</tr>
</table>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<TR>
<td align="right">
<table class="TableBorder" id="tblTopInfo" cellSpacing="0"
cellPadding="3" width="303"
border="0">
<tr>
<td style="WIDTH: 87px">Report Name:</td>
<td><asp:label id="lblReportName"
runat="server">lblReportName</asp:label></td>
</tr>
<tr>
<td style="WIDTH: 87px">Report Version:</td>
<td><asp:label id="lblReportVersion"
runat="server">lblReportVersion</asp:label></td>
</tr>
</table>
</td>
</TR>
</table>
<table id="Table3" cellSpacing="0" cellPadding="3" width="100%"
border="0">
<tr>
<td><asp:label id="lblError" runat="server" font-bold="True"
forecolor="Red"></asp:label></td>
</tr>
</table>
<table class="TableBorder" id="Table4" cellSpacing="0"
cellPadding="3" width="100%" border="0">
<tr>
<td class="THList" style="WIDTH: 140px"
colSpan="4"><asp:label id="lblReportDetails" runat="server" cssclass="H1"
width="316px">Report Details</asp:label></td>
</tr>
<tr>
<td style="WIDTH: 140px"><asp:label id="lblName"
runat="server" width="109px">Report Name:</asp:label></td>
<td style="WIDTH: 149px"><asp:textbox id="txtName"
runat="server" width="108px" maxlength="6"></asp:textbox></td>
<td style="WIDTH: 153px"><asp:label id="lblVersion"
runat="server" width="109px">Report Version:</asp:label></td>
<td><asp:textbox id="txtVersion" runat="server"
width="108px" maxlength="2"></asp:textbox></td>
</tr>
<tr>
<td style="WIDTH: 140px"><asp:label id="lblFullName"
runat="server" width="109px">Full Name:</asp:label></td>
<td style="WIDTH: 192px" colSpan="3"><asp:textbox
id="txtFullName" runat="server" width="544px"
maxlength="32"></asp:textbox></td>
</tr>
<tr>
<td style="WIDTH: 140px"><asp:label id="lblTemplateName"
runat="server" width="109px">Template Name:</asp:label></td>
<td style="WIDTH: 149px"><asp:textbox id="txtTemplateName"
runat="server" width="107px" maxlength="8"></asp:textbox></td>
<td style="WIDTH: 153px"></td>
<td></td>
</tr>
<tr>
<td style="WIDTH: 140px"><asp:label id="lblOrientation"
runat="server" width="109px">Orientation:</asp:label></td>
<td style="WIDTH: 149px"><asp:textbox id="txtOrientation"
runat="server" width="107px" maxlength="1"></asp:textbox></td>
<td style="WIDTH: 153px"><asp:label id="lblType"
runat="server" width="109px">Type:</asp:label></td>
<td style="WIDTH: 121px"><asp:textbox id="txtType"
runat="server" width="107px" maxlength="1"></asp:textbox></td>
</tr>
<tr>
<td style="WIDTH: 140px"><asp:label id="lblRetainage"
runat="server" width="109px">Retainage:</asp:label></td>
<td style="WIDTH: 149px"><asp:textbox id="txtRetainage"
runat="server" width="107px" maxlength="5"></asp:textbox></td>
<td style="WIDTH: 153px"><asp:label id="lblEmailOptions"
runat="server" width="109px">Email Options:</asp:label></td>
<td style="WIDTH: 121px"><asp:textbox id="txtEmailOptions"
runat="server" width="107px" maxlength="1"></asp:textbox></td>
</tr>
</table>
<br>
<table class="TableBorder" id="Table7" cellSpacing="0"
cellPadding="3" width="100%" border="0">
<tr>
<td class="THList" style="WIDTH: 140px" colSpan="4">Report
Paramters</td>
</tr>
<tr>
<td style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
PADDING-BOTTOM: 0px; PADDING-TOP: 0px"><asp:table id="tblParamters"
runat="server" cssclass="tableBorderList" width="100%"></asp:table></td>
</tr>
</table>
<br>
<table id="Table8" cellSpacing="0" cellPadding="3" width="100%"
border="0">
<tr>
<td style="WIDTH: 66px"></td>
<td style="WIDTH: 79px"><asp:imagebutton id="ibtnBack"
runat="server" imageurl="Images\btn_Back.jpg"></asp:imagebutton></td>
<td style="WIDTH: 158px"></td>
<td style="WIDTH: 435px"></td>
<td style="WIDTH: 4px"><asp:imagebutton id="ibtnCancel"
runat="server" imageurl="Images\btn_cancel.jpg"></asp:imagebutton></td>
<td><asp:imagebutton id="ibtnAdd" runat="server"
imageurl="Images\btnAdd.gif"></asp:imagebutton></td>
<td><asp:imagebutton id="ibtnEdit" runat="server"
imageurl="Images\btn_Edit.jpg"></asp:imagebutton></td>
<td><asp:imagebutton id="ibtnDelete" runat="server"
imageurl="Images\btnDelete.gif"></asp:imagebutton></td>
<td><asp:imagebutton id="ibtnSave" runat="server"
imageurl="Images\btnSave.gif"
causesvalidation="False"></asp:imagebutton></td>
</tr>
</table>
<table id="Table9" cellSpacing="0" cellPadding="3" width="100%">
<tr>
<td style="HEIGHT: 10px" align="right"><asp:label
id="lblReloadInfo" runat="server" visible="False"></asp:label><asp:label
id="lblBackLink" runat="server" visible="False"></asp:label></td>
</tr>
</table>
<table id="BottomTable" cellSpacing="0" cellPadding="3"
width="100%" border="0">
<tr>
<td style="HEIGHT: 11px"><asp:label id="lblDebugMsg"
runat="server" forecolor="#804040"></asp:label><asp:label id="lblFilter"
runat="server" visible="False"></asp:label></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</HTML>

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
Can you post the .cs file as well?

Nov 16 '05 #3

P: n/a
YAY!!!! that worked thanks

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...
Do you initialize the text in the textbox to start with?

E.G: Say in the Form_Load event

txtFullName.Text = "";

because if you have you want to change it to this instead.

if(IsPostBack!=true)
{
txtFullName.Text = "";
}

Nov 16 '05 #4

P: n/a
Jax
Splendid, thats fixed then eh

Jax
Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.