asp.net - form control values are not reloaded on postback -


i in process of migrating user controls 1 version of project new version. there errors in project while trying change version, created new project , started copying pages , controls. have got of controls copied over, , in process of copying on pages. testing go.

with being said, working on control , noticed having problems required field validators. these fields not dynamic, there. fields failing tests required validators had data in them. there 3 having problems. 3 text fields. able convert 2 of validators custom validators , able them working, third still not work.

the custom validator not working fails because value page not reloaded in control. when check posted form using control's unique id, data exists. cause disconnect? understand controls supposed reloaded post data before control's events fired. appears process broken. happening?

the fields in question txttitle, txtdescription, , txtsendnoticeto.

html:

<%@ control language="vb" autoeventwireup="false" codebehind="projectinformation.ascx.vb" inherits="kdoc.projectinformation" %> <%@ register tagprefix="cc1" namespace="sqlinjectioncontrols" assembly="sqlinjectioncontrols" %>  <script type="text/javascript"> <!-- function addsendtoname() {      var textfield = document.getelementbyid('ctl08_txtsendnoticeto');     //      alert(document.getelementbyid(textfieldid));      if (textfield.value.length > 0) {         textfield.value += "; " + document.getelementbyid('ctl08_ddlsendtonames').value;     } else {         textfield.value = document.getelementbyid('ctl08_ddlsendtonames').value;     } } //--> </script>  <table class="fullwidth padding-2 spacing-3" border="0"> <tr>     <td class="nowrap" style="width: 15%">platform&nbsp;<span class="required">*</span></td>     <td style="width: 35%">         <asp:dropdownlist id="ddlplatform" runat="server"/><br/>         <asp:requiredfieldvalidator id="reqplatform" runat="server" controltovalidate="ddlplatform" display="dynamic" errormessage="required"/>     </td>     <td colspan="2" class="right">         <asp:linkbutton id=btnchangenotice causesvalidation=false runat=server text="change notice report" visible=false />     </td> </tr> <tr>     <td class="nowrap" style="width: 15%">area manager&nbsp;<span class="required">*</span></td>     <td style="width: 35%">         <asp:dropdownlist id="ddlsystem" width="100%" runat="server"/><br/>         <asp:requiredfieldvalidator id="reqsystem" runat="server" controltovalidate="ddlsystem" display="dynamic" errormessage="required"/>     </td>     <td class="nowrap" style="width: 15%">application</td>     <td style="width: 35%">         <asp:textbox id="txtapplication" width="100%" maxlength="100" runat="server"/>         <cc1:sqlinjectionvalidator id="sqlapplication" runat="server" controltovalidate="txtapplication" errormessage="error in input field"/>     </td> </tr> <tr>     <td class="nowrap" style="width: 15%">menu</td>     <td style="width: 35%">         <asp:textbox id="txtmenu" width="100%" maxlength="100" runat="server"/>         <cc1:sqlinjectionvalidator id="sqlmenu" runat="server" controltovalidate="txtmenu" errormessage="error in input field"/>     <td class="nowrap" style="width: 15%">step</td>     <td style="width: 35%">         <asp:textbox id="txtmenustep" width="100%" maxlength="100" runat="server"/>         <cc1:sqlinjectionvalidator id="sqlmenustep" runat="server" controltovalidate="txtmenustep" errormessage="error in input field"/>     </td> <tr>     <td class="nowrap" style="width: 15%">title&nbsp;<span class="required">*</span></td>     <td colspan="3">         <asp:textbox id="txttitle" width="100%" maxlength="100" runat="server"/>         <asp:customvalidator id="cvtitle" runat="server" controltovalidate="txttitle" display="dynamic" errormessage="required" />         <cc1:sqlinjectionvalidator id="sqltitle" runat="server" controltovalidate="txttitle" errormessage="error in input field"/>     </td> </tr> <tr class="top">     <td class="nowrap" style="width: 15%">description&nbsp;<span class="required">*</span></td>     <td colspan="3">         <asp:textbox id="txtdescription" width="100%" runat="server" height="150" textmode="multiline"/>         <asp:customvalidator id="cvdescription" runat="server" controltovalidate="txtdescription" display="dynamic" errormessage="required" />         <cc1:sqlinjectionvalidator id="sqldescription" runat="server" controltovalidate="txtdescription" errormessage="error in input field"/>     </td> </tr> <tr class="top">     <td style="width: 15%">special instructions</td>     <td colspan="3">         <asp:textbox id="txtspecialinstructions" width="100%" runat="server" height="150" textmode="multiline"/>         <cc1:sqlinjectionvalidator id="sqlspecialinstructions" runat="server" controltovalidate="txtspecialinstructions" errormessage="error in input field"/>     </td> </tr> <tr>     <td class="boxheader" colspan="4">notification information</td> </tr> <tr>     <td class="nowrap" style="width: 15%">requesting branch</td>     <td style="width: 35%">         <asp:textbox id="txtrequestingbranch" runat="server" maxlength="4"/><br/>         <cc1:sqlinjectionvalidator id="sqlrequestingbranch" runat="server" errormessage="error in input field" controltovalidate="txtrequestingbranch" />     </td>     <td class="nowrap" style="width: 15%">requestor</td>     <td style="width: 35%">         <asp:textbox id="txtrequestor" runat="server" maxlength="30"/><br/>         <cc1:sqlinjectionvalidator id="sqlrequestor" runat="server" errormessage="error in input field" controltovalidate="txtrequestor"/>     </td> </tr> <tr>     <td class="nowrap" style="width: 15%">is contact&nbsp;<asp:label id=lblcontactrequired runat=server cssclass="required" text="*"/></td>     <td style="width: 35%">         <asp:textbox id="txtcontact" runat="server" maxlength="30"/><br/>         <asp:customvalidator id="cvcontact" runat="server" display="dynamic" controltovalidate="ddlplatform" errormessage="required" />         <cc1:sqlinjectionvalidator id="sqlcontact" runat="server" errormessage="error in input field" controltovalidate="txtcontact" />     </td>     <td class="nowrap" style="width: 15%">branches</td>     <td style="width: 35%">         <asp:textbox id="txtbranches" runat="server" maxlength="50"/><br/>         <cc1:sqlinjectionvalidator id="sqlbranches" runat="server" errormessage="error in input field" controltovalidate="txtbranches" />     </td> </tr> <tr>     <td class="nowrap" style="width: 15%">default names</td>     <td colspan="3">         <asp:dropdownlist id="ddlsendtonames" runat="server" datatextfield="description" datavaluefield="description"/>         &nbsp;<input type="button" id="btnaddname" value="add name" runat="server" name="btnaddname"  onclick="addsendtoname();" />     </td> </tr> <tr>     <td class="nowrap" style="width: 15%">send notice to&nbsp;<asp:label id=lblsendtorequired runat=server cssclass="required" text="*"/></td>     <td colspan="3">         <asp:textbox id="txtsendnoticeto" runat="server" width="100%" textmode="multiline" height="120" />         <asp:customvalidator id="cvsendnoticeto" runat="server" display="dynamic" controltovalidate="ddlplatform" errormessage="required" />         <cc1:sqlinjectionvalidator id="sqlsendnoticeto" runat="server" errormessage="error in input field" controltovalidate="txtsendnoticeto"/>     </td> </tr> </table> 

code behind:

public class projectinformation inherits system.web.ui.usercontrol   #region "attributes" private mypackage projectpackage #end region  #region "events" ''' <summary> ''' transfer page on change notice report ''' </summary> ''' <remarks> ''' </remarks> protected sub btnchangenotice_click(byval sender object, byval e system.eventargs) handles btnchangenotice.click     dim querystring new stringbuilder     querystring.append("reportloader.aspx?")     querystring.append(querystring_report).append("=")     querystring.append(report_name_changenotice)     'querystring.append("&").append(querystring_parameter).append("=").append(ctype(me.parent.findcontrol("txtpackageid"), textbox).text)     querystring.append("&").append(querystring_parameter).append("=").append(mypackage.packageid)     querystring.append("&").append(querystring_format).append("=")     querystring.append(report_format_acrobat)      response.redirect(querystring.tostring, true) end sub  protected sub cvcontact_servervalidate(byval source object, byval args system.web.ui.webcontrols.servervalidateeventargs) handles cvcontact.servervalidate     dim pt string = ctype(parent.findcontrol("ddlprojecttype"), dropdownlist).selectedvalue      if pt.tolower.equals("chg") , txtcontact.text.equals(string.empty)         args.isvalid = false     else         args.isvalid = true     end if end sub  private sub cvdescription_servervalidate(source object, args system.web.ui.webcontrols.servervalidateeventargs) handles cvdescription.servervalidate     args.isvalid = cbool(txtdescription.text.length > 0) end sub  protected sub cvsendnoticeto_servervalidate(byval source object, byval args system.web.ui.webcontrols.servervalidateeventargs) handles cvsendnoticeto.servervalidate     dim pt string = ctype(parent.findcontrol("ddlprojecttype"), dropdownlist).selectedvalue      if pt.tolower.equals("chg") , txtsendnoticeto.text.length = 0         args.isvalid = false     else         args.isvalid = true     end if end sub  private sub cvtitle_servervalidate(source object, args system.web.ui.webcontrols.servervalidateeventargs) handles cvtitle.servervalidate     args.isvalid = cbool(txttitle.text.length > 0) end sub #end region  #region "functions" private sub binddata()     bindplatform()     bindsystems()     bindsendtonames() end sub  private sub bindplatform()     dim pl new businesslayer.platformcollection     pl.load()      ddlplatform.datasource = pl     ddlplatform.datatextfield = "description"     ddlplatform.datavaluefield = "platformid"     ddlplatform.databind()      ddlplatform.items.insert(0, "")      try         ddlplatform.selectedvalue = mypackage.platform.platformid     catch ex exception         ddlplatform.items.clear()         ddlplatform.items.insert(0, new web.ui.webcontrols.listitem("select platform", ""))         ddlplatform.selectedindex = 0     end try end sub  private sub bindsendtonames()     dim st new businesslayer.sendtocollection     st.load()      ddlsendtonames.datasource = st     ddlsendtonames.databind() end sub  private sub bindsystems()     dim sm new systemmanagercollection     sm.load()      ddlsystem.datasource = sm     ddlsystem.datatextfield = "name"     ddlsystem.datavaluefield = "managerid"     ddlsystem.databind()      ddlsystem.items.insert(0, "")      try         ddlsystem.selectedvalue = mypackage.systemmanager.managerid     catch ex exception         ddlsystem.items.clear()         ddlsystem.items.insert(0, new web.ui.webcontrols.listitem("manager not found", ""))         ddlsystem.selectedindex = 0     end try end sub  ''' <summary> ''' used set permissions on controls ''' </summary> ''' <remarks> ''' </remarks> public sub disablecontrols()     mypackage = ctype(context.session(session_package), projectpackage)     dim bum new systemmanager     bum.loadbackupmanagerbymanager(mypackage.systemmanager.managerid)      if mypackage.systemmanager.managerid.tolower.equals(context.user.identity.name.tolower) or _        bum.managerid.tolower.equals(context.user.identity.name.tolower)         if (mypackage.status.id = packagestatusenum.readyformanager or _            mypackage.status.id = packagestatusenum.deniedformanager)             ddlplatform.enabled = false             ddlsystem.enabled = false             txtapplication.enabled = false             txtmenu.enabled = false             txtmenustep.enabled = false             txttitle.enabled = false             txtspecialinstructions.enabled = false         else             ddlplatform.enabled = false             ddlsystem.enabled = false             txtapplication.enabled = false             txtmenu.enabled = false             txtmenustep.enabled = false             txtdescription.enabled = false             txttitle.enabled = false             txtspecialinstructions.enabled = false         end if      else         ddlplatform.enabled = false         ddlsystem.enabled = false         txtapplication.enabled = false         txtmenu.enabled = false         txtmenustep.enabled = false         txttitle.enabled = false         txtdescription.enabled = false         txtspecialinstructions.enabled = false     end if      ' notification section     txtrequestingbranch.enabled = false     txtrequestor.enabled = false     txtcontact.enabled = false     txtbranches.enabled = false     ddlsendtonames.enabled = false     btnaddname.disabled = true     txtsendnoticeto.enabled = false end sub  ''' <summary> ''' unlock controls change control able update ''' </summary> ''' <remarks> ''' </remarks> public sub enablecontrolsforchangecontrol()     txttitle.enabled = true     txtdescription.enabled = true     txtspecialinstructions.enabled = true     ' notification section     ddlsendtonames.enabled = true     btnaddname.disabled = false     txtsendnoticeto.enabled = true end sub  ''' <summary> ''' unlock controls package manager ''' </summary> ''' <remarks> ''' </remarks> public sub enablecontrolsformanager()     ddlplatform.enabled = true     ddlsystem.enabled = true     txtapplication.enabled = true     txtmenu.enabled = true     txtmenustep.enabled = true     txttitle.enabled = true     txtdescription.enabled = true     txtspecialinstructions.enabled = true     txtcontact.enabled = true     txtbranches.enabled = true     txtsendnoticeto.enabled = true end sub  ''' <summary> ''' overridden function load of form variables control ''' </summary> ''' <remarks> ''' </remarks> public shadows sub load()     mypackage = ctype(context.session(session_package), projectpackage)      binddata()     setformvars()      btnchangenotice.visible = cbool(mypackage.status.id > packagestatusenum.readyformanager) end sub  ''' <summary> ''' toggle visibility of required field markers ''' </summary> ''' <param name="required">required indicator</param> ''' <remarks> ''' </remarks> public sub requirenotification(byval required boolean)     lblsendtorequired.visible = required     lblcontactrequired.visible = required end sub  ''' <summary> ''' set values of controls package , project information ''' </summary> ''' <remarks> ''' </remarks> private sub setformvars()     txtapplication.text = mypackage.application     txtmenu.text = mypackage.menu     txtmenustep.text = mypackage.menustep     txttitle.text = mypackage.title     txtdescription.text = mypackage.description     txtspecialinstructions.text = mypackage.specialinstructions      mypackage.project.load()     txtrequestingbranch.text = mypackage.project.requestinglocation     txtrequestingbranch.enabled = false     txtrequestor.text = mypackage.project.requestorname     txtrequestor.enabled = false     txtcontact.text = mypackage.contact     txtbranches.text = mypackage.branches     txtsendnoticeto.text = mypackage.sendnoticeto end sub  ''' <summary> ''' update project package data contained within module ''' </summary> ''' <remarks> ''' </remarks> public sub update()     mypackage = ctype(context.session(session_package), projectpackage)      if mypackage.status.id >= packagestatusenum.readyfordirector exit sub      mypackage.platform.platformid = ddlplatform.selectedvalue     mypackage.systemmanager.managerid = ddlsystem.selectedvalue     mypackage.application = txtapplication.text     mypackage.menu = txtmenu.text     mypackage.menustep = txtmenustep.text     mypackage.title = txttitle.text     mypackage.description = txtdescription.text     mypackage.specialinstructions = txtspecialinstructions.text     mypackage.contact = txtcontact.text     mypackage.branches = txtbranches.text     mypackage.sendnoticeto = txtsendnoticeto.text     mypackage.updateinformation(context.user.identity.name)      'if ddlsendtonames.enabled     '    'mypackage.project.requestinglocation = txtrequestingbranch.text     '    'mypackage.project.requestorname = txtrequestor.text     '    mypackage.contact = txtcontact.text     '    mypackage.branches = txtbranches.text     '    mypackage.sentnoticeto = txtsendnoticeto.text     '    mypackage.project.updatenotificationinfo()     'end if     context.session(session_package) = mypackage end sub #end region  #region "properties" 'public property package() businesslayer.projectpackage '    '        return mypackage '    end '    set(byval value businesslayer.projectpackage) '        mypackage = value '    end set 'end property  public readonly property platform() string             return ddlplatform.selectedvalue     end end property  public readonly property systemmanager() string             return ddlsystem.selectedvalue     end end property  public readonly property applicationname() string             return txtapplication.text     end end property  public readonly property menu() string             return txtmenu.text     end end property  public readonly property menustep() string             return txtmenustep.text     end end property  public readonly property title() string             return txttitle.text     end end property  public readonly property description() string             return txtdescription.text     end end property  public readonly property specialinstructions() string             return txtspecialinstructions.text     end end property #end region  end class 

change function this:

function addsendtoname() {      var textfield = document.getelementbyid('<%= txtsendnoticeto.clientid %>');     //      alert(document.getelementbyid(textfieldid));      if (textfield.value.length > 0) {         textfield.value += "; " + document.getelementbyid('<%= ddlsendtonames.clientid %>').value;     } else {         textfield.value = document.getelementbyid('<%= ddlsendtonames.clientid %>').value;     } } 

while these names may have worked in previous code, probable browser generating new/different names have changed things around. writing them way, ensures right ids on dom.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -