Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mikica
Starting Member
9 Posts |
Posted - 2007-05-09 : 13:55:01
|
On one form I have check box, label, dropdown, 3 buttons, 3 text boxes.On one place I set values for them.On submit label looses its text, buttons looses captions, dropdown looses all its items but check box and text boxes have their values still on them.I checked all IsPostback options. They are all treated same way on same places but behaves differently. Anybody have some option? |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-05-09 : 15:10:00
|
I think the problem is in your code on line 42, you are setting x equal to 1 when it has been initialized yet. That's what my crystal ball that magically shows me all of your code is telling me ...it doesn't always work that well, though. If that's not it, maybe try providing some actual code/details ?- Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
mikica
Starting Member
9 Posts |
Posted - 2007-05-10 : 03:50:43
|
Code behind:namespace hrast.Controls.Employee{ using System; using System.Data; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Collections; /// <summary> /// RequiredPayrollItems. /// </summary> public class ExtendedAdminManagePayrollItems : hrast.Components.BaseControlElement { public System.Web.UI.WebControls.Button uxCancelButton; public System.Web.UI.WebControls.Button uxSaveButton; public System.Web.UI.WebControls.Button uxHistoryButton; public System.Web.UI.WebControls.TextBox txtEmployeePayrollItemId; public System.Web.UI.WebControls.TextBox txtPayrollItemValue; public System.Web.UI.WebControls.TextBox txtPayrollItemComment; public System.Web.UI.WebControls.TextBox txtOrgUnitList; public System.Web.UI.WebControls.TextBox txtEarnedFrom; public System.Web.UI.WebControls.TextBox txtEarnedTo; public System.Web.UI.WebControls.CheckBox chkPayrollItemApproved; public System.Web.UI.WebControls.Label lblItemName; public string _call_refresh = ""; public string _url_employee = ""; public string _url_payroll_history = ""; public string PersonId { get { return Request.Params["pid"]; } } private void Page_Load(object sender, System.EventArgs e) { hrast.Proxy.CommonService.Common _service = new hrast.Proxy.CommonService.Common(); hrast.Proxy.LookupService.LookUpService ls = new hrast.Proxy.LookupService.LookUpService(); hrast.Proxy.LookupService.PayrollPeriod _payrollPeriod = new hrast.Proxy.LookupService.PayrollPeriod(); _url_employee = "Main.aspx?ID=" + _service.UcReadModuleIdForSrc ("/hrast/Controls/Employee/EmployeeEdit.ascx"); _url_payroll_history = "Main.aspx?ID=" + _service.UcReadModuleIdForSrc ("/hrast/Controls/Employee/PayrollHistoryList.ascx"); if (!IsPostBack) { this.FillData(); this.InitText(); } } void InitText() { uxCancelButton.Text = resText["uxCancelButton"].ToString(); uxSaveButton.Text = resText["uxSaveButton"].ToString(); uxHistoryButton.Text = resText["History"].ToString(); } protected void Cancel(object sender, System.EventArgs e) { _call_refresh = "<script>window.parent.CloseDetail();</script>"; } protected void Save(object sender, System.EventArgs e) { Proxy.Employement.Employement _service = new hrast.Proxy.Employement.Employement(); int epiId = -999; string comment = ""; double epiValue = 0; bool approved = false; int orgId; string accCode; string fromDate; string toDate; string earnedFromDate; string earnedToDate; string appUserId; int updUserId; bool isDirty = false; DataRow _row = (DataRow)Session["currDR"]; string oldComment = _row["Comment"].ToString(); string oldValue = _row["payrollitemvalue"].ToString(); try { epiId = Convert.ToInt32(txtEmployeePayrollItemId.Text); comment = txtPayrollItemComment.Text; if(oldComment != comment) isDirty = true; epiValue = 0; if (txtPayrollItemValue.Text != "") { try { epiValue = Convert.ToDouble(txtPayrollItemValue.Text.Replace(".", "")); if(epiValue != double.Parse(oldValue)) isDirty = true; } catch { throw new ApplicationException("IVAL_DOUBLE_VALUE"); } } else throw new ApplicationException("IVAL_REQ_VALUE"); approved = chkPayrollItemApproved.Checked; } catch (ApplicationException exp) { hrast.Controls.Sys.ErrorHandling.HrastErrorRedirecter thisErrHandl = new hrast.Controls.Sys.ErrorHandling.HrastErrorRedirecter(this, exp); return; } try { orgId = Convert.ToInt32(txtOrgUnitList.Text); } catch { orgId = -1; } accCode = Convert.ToString(_row["AccountingCode"]); fromDate = Convert.ToString(_row["FromDate"]); toDate = Convert.ToString(_row["ToDate"]); earnedFromDate = txtEarnedFrom.Text; earnedToDate = txtEarnedTo.Text; appUserId = "-1"; bool wasApproved = Convert.ToBoolean(_row["Approved"]); if (wasApproved && !approved) appUserId = ""; else if (!wasApproved && approved) appUserId = SessionObject.UserID.ToString(); updUserId = SessionObject.UserID; if(txtEmployeePayrollItemId.Text != "0") _service.EmployeePayrollItemsUpdate(epiId, orgId, accCode, fromDate, toDate, earnedFromDate, earnedToDate, epiValue, comment, approved, appUserId, updUserId); else _service.EmployeePayrollItemsInsert(Convert.ToInt32(Request.Params["pid"]), Convert.ToInt32(Request.Params["ppid"]), orgId, accCode, fromDate, toDate, earnedFromDate, earnedToDate, Convert.ToInt32(Request.Params["itemId"]), epiValue, comment, approved, Convert.ToInt32(appUserId), updUserId); //this.FillData(); _call_refresh = "<script> window.parent.ThisDoSearch(); </script>"; } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // this.GetResources(@"Controls\Employee\ExtendedAdminManagePayrollItems.xml"); 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.Load += new System.EventHandler(this.Page_Load); this.uxHistoryButton.Attributes.Add ("onclick", "ShowEmpHistory(" + Request.Params["itemId"] + ", " + Request.Params["pid"] + ", " + Request.Params["ppid"] + "); return false;"); } #endregion private string FormatValue(string _val) { string begin = ""; string end = ""; if(_val.IndexOf(",") != -1) { begin = _val.Substring(0, _val.IndexOf(",")); end = _val.Substring(_val.IndexOf(",")+1); } else { begin = _val; } string begin_rez = ""; int cnt = 0; for(int i = begin.Length; i>0; i--) { cnt++; string chr = begin.Substring(i-1, 1); begin_rez = chr + begin_rez; if(cnt == 3 && i != 1) { cnt = 0; begin_rez = "." + begin_rez; } } if(end =="") return begin_rez; else return begin_rez + "," + end; } /// <summary> /// Fills data from proxy to webservice. /// </summary> private void FillData() { hrast.Proxy.LookupService.LookUpService ls = new hrast.Proxy.LookupService.LookUpService(); DataSet dss = ls.OrganizationLookup_GetAllInternal();/* ddlOrgUnitList.DataSource = dss; ddlOrgUnitList.DataValueField = "Organizations.OrganizationID"; ddlOrgUnitList.DataTextField = "Organizations.Name"; ddlOrgUnitList.DataBind();*/ Proxy.Employement.Employement _service = new hrast.Proxy.Employement.Employement(); DataSet tmpDS = new DataSet("Tmp"); tmpDS = _service.GetEmployeePayrollItemsExtended(Request.Params["pid"], Request.Params["ppid"], Request.Params["itemId"], SessionObject.LanguageCode); DataRow currDR = tmpDS.Tables[0].Rows[0]; Session["currDR"] = currDR; double tmpNum = 0; txtEmployeePayrollItemId.Text = Convert.ToString(currDR["employeepayrollitemid"]); lblItemName.Text = Convert.ToString(currDR["name"]); txtPayrollItemComment.Text = Convert.ToString(currDR["comment"]); try { txtOrgUnitList.Text = Convert.ToString(currDR["costcenterorganizationid"]); } catch { txtOrgUnitList.Text = "0"; } try { txtEarnedFrom.Text = Convert.ToDateTime(currDR["earnedfromdate"]).ToShortDateString(); } catch { txtEarnedFrom.Text = ""; } try { txtEarnedTo.Text = Convert.ToDateTime(currDR["earnedtodate"]).ToShortDateString(); } catch { txtEarnedTo.Text = ""; } if (Convert.ToString(currDR["payrollitemvalue"]) != "") { txtPayrollItemValue.Attributes.Add("onkeyup","ChangeValueReq('" + txtPayrollItemValue.ClientID + "');"); if(Convert.ToString(currDR["payrollitemvalue"]) == "0") txtPayrollItemValue.Text = "0"; else { tmpNum = Convert.ToDouble(currDR["payrollitemvalue"]); string _vl = tmpNum.ToString("###############.#######"); if(_vl.IndexOf(",") == 0) _vl = "0" + _vl; txtPayrollItemValue.Text = FormatValue(_vl); } } if(Convert.ToString(currDR["approved"]) != "") chkPayrollItemApproved.Checked = Convert.ToBoolean(currDR["approved"]); } }}and front page:<%@ Control Language="c#" AutoEventWireup="false" Codebehind="ExtendedAdminManagePayrollItems.ascx.cs" Inherits="hrast.Controls.Employee.ExtendedAdminManagePayrollItems" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %><script>function ShowEmpData(){ window.open ("<%=_url_employee %>" + "&itemid=" + <%=PersonId %>, '_blank', "height=650, width=800,top=50,left=150,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");}function ShowEmpHistory(payrollItemId, pId, payrollPeriodId){ window.open ("<%=_url_payroll_history %>" + "&itemid=" + payrollItemId + '&pid=' + pId + '&ppid=' + payrollPeriodId, '_blank', "height=650, width=800,top=50,left=150,status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes");}function BadValueInput(valueInput){ var strValue = valueInput.value; var cle = ""; if(strValue.indexOf(",") != -1) { cle = strValue.substring(0, strValue.indexOf(",")); } else if(strValue.indexOf(".") != -1) { cle = strValue.substring(0, strValue.indexOf(".")); } else { cle = strValue; } if (cle.length > 15) { strValue = strValue.substring(0,15); if(valueInput.value.indexOf(",") != -1) { strValue = strValue + "," + valueInput.value.substring(valueInput.value.indexOf(",")+1, valueInput.value.length); } if(valueInput.value.indexOf(".") != -1) { strValue = strValue + "." + valueInput.value.substring(valueInput.value.indexOf(".")+1, valueInput.value.length); } valueInput.value = strValue; return false; } if (strValue.indexOf(",") != -1) { var rez = strValue.substring((strValue.indexOf(",") + 1), strValue.length); if (rez.length > 7) { valueInput.value = strValue.substring(0, strValue.indexOf(",") + 8); return false; } } if (strValue.indexOf(".") != -1) { var rez = strValue.substring((strValue.indexOf(".") + 1), strValue.length); if (rez.length > 7) { valueInput.value = strValue.substring(0, strValue.indexOf(".") + 8); return false; } }}function ChangeValueReq(objjjj){ var val =document.getElementById(objjjj); var data = val.value; var xp = 0; while (xp != -1) { data = data.replace(".", ""); xp = data.indexOf("."); } var end = ""; if(data.indexOf(",") != -1) { end = data.substring(data.indexOf(","), data.length); } var start = ""; if(data.indexOf(",") != -1) { start = data.substring(0, data.indexOf(",")); } else { start = data; } data = start; var i = 0; var count = 0; var tmpStr = ""; var comma = "."; for (i = data.length-1; i >= 0; i--) { if (count == 3) { tmpStr += comma; count = 1; } else { count ++; } tmpStr += data.charAt(i); } var x = 0; var res = ""; for (x = tmpStr.length-1; x >= 0; x--) { res += tmpStr.charAt(x); } val.value = res + end;}</script><table oncontextmenu="return false;" id="ctlTable" cellSpacing="0" cellPadding="0" width="100%" border="0"> <tr> <td width="100%" class="frame" align="right"> <table width="100%" cellSpacing="0" cellPadding="0" border="0"> <tr> <td width="35%" valign="top" class="text"> <%= resText["Name"] %> </td> <td width="15%" valign="top" class="text"> <%= resText["Value"] %> </td> <td width="20%" valign="top" class="text"> <%= resText["OrgUnit"] %> </td> <td width="10%" valign="top" class="text"> <%= resText["EarnedFrom"] %> </td> <td width="10%" valign="top" class="text"> <%= resText["EarnedTo"] %> </td> </tr> <tr> <td width="35%" valign="top" class="text"> <asp:TextBox ID="txtEmployeePayrollItemId" Visible="True" Runat="server" Width="0px"/> <b><asp:Label ID="lblItemName" Runat="server"></asp:Label></b> </td> <td width="15%" valign="top" class="text"> <asp:TextBox ID="txtPayrollItemValue" Width="95%" Runat="server" /> </td> <td width="20%" valign="top" class="text"> <asp:TextBox ID="txtOrgUnitList" Width="95%" Visible="True" Runat="server"></asp:TextBox> </td> <td width="15%" valign="top" class="text"> <asp:TextBox ID="txtEarnedFrom" Width="75%" Runat="server"/> <IMG id="imgFromDate" title="Date selector" style="CURSOR: pointer" src="images/cal.gif" align="middle"> </td> <td width="15%" valign="top" class="text"> <asp:TextBox ID="txtEarnedTo" Width="75%" Runat="server" /> <IMG id="imgToDate" title="Date selector" style="CURSOR: pointer" src="images/cal.gif" align="middle"> </td> </tr> <tr> <td valign="top" class="text" colspan="4"> <br><%= resText["Comment"] %><br> <asp:TextBox ID="txtPayrollItemComment" Width="100%" Runat="server"/> </td> <td valign="top" align="center" class="text"> <br><%= resText["Approved"] %><br> <asp:CheckBox ID="chkPayrollItemApproved" Width="95%" Runat="server" /> </td> </tr> </table> <br><input id=cmdShowEmpData" type="button" value="<%= resText["l_emp_data"]%>" onclick="ShowEmpData();"> <asp:Button id="uxCancelButton" runat="server" Width="80px" OnClick="Cancel"></asp:Button> <asp:Button id="uxSaveButton" runat="server" Width="80px" OnClick="Save"></asp:Button> <asp:Button id="uxHistoryButton" runat="server" Width="80px" EnableViewState="true"></asp:Button> </td> </tr></table><%=_call_refresh %><script language="jscript"> Calendar.setup( { inputField : "<%= txtEarnedFrom.ClientID %>", // ID of the input field ifFormat : "<%= this.DateFormat %>", // the date format button : "imgFromDate", // ID of the button align : "Tl" } ); Calendar.setup( { inputField : "<%= txtEarnedTo.ClientID %>", // ID of the input field ifFormat : "<%= this.DateFormat %>", // the date format button : "imgToDate", // ID of the button align : "Tl" } );</script>Something new? |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-05-10 : 08:33:50
|
Just dumping all of your code onto the page is almost as bad as providing no information! How about at least highlighting where the problems are occurring, or omitting parts that aren't relevant to the problem? That process is actually something that you should be doing on your own, anyway, even if you aren't asking someone else for help, since it is a valuable and important thing to do when going through a trouble-shooting or debugging process.Anyway:>>On submit label looses its text, buttons looses captions, ...I see that one button has EnabledViewState=True, the others don't. Did you try enabling viewstate for the buttons and labels that are losing their values ??>> dropdown looses all its items but check box and text boxes have their values still on them.I don't even see any DropDownLists on your page anywhere ... - Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
mikica
Starting Member
9 Posts |
Posted - 2007-05-14 : 14:13:13
|
Yeah... my mistake. I switched drop down with text box to see will it have View State preserved and it did. It mean that drop down does not hold view state for some reason and text box do.In method FillData() I set values to all controls on page. If I do save without required value I get error handled message and those conrols are not populated. If I do save with all correct entered values I get error that drop down do not have SelectedValue. This lines I pasted behave the same way just there is no drop down. Labels loose their text values and buttons their captions. I still have not found solution.Thanks for trying to help. |
|
|
|
|
|
|
|