The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
javascript not picking up hidden field values
Posted: 07 Apr 08 8:21 PM
|
Ihave some hidden fields that hold various pieces of data determining whether javascript should fire or not. I had these in textboxes thinking I could just hide the panel they were on when it was time.. Well, I hid the panel and the values are not available.
So I moved from hidden textboxes to hiddenfields. The C# seems to pick this up fine, but the javascript is coming up blank. The hidden fields are getting the proper values.
HTML
C# FormType.Value = Request.QueryString["certtype"]; Javascript document.getElementById('ctl00_MainContent_DivXCertificationApplication_FormType').value == 'odm')
When FormType was a textbox everything worked fine. I double checked the control name in the source of the rendered web form.
Any thoughts? thanks |
|
|
|
Re: javascript not picking up hidden field values
Posted: 07 Apr 08 11:15 PM
|
Basically this should work fine since you are working entirely in Javascript with no ASP.NET or Saleslogix involved... Have you tried bringing up the form in firebug and echoing the value, or adding an "alert" statement in your JS?
One problem (though probably not the case here since you checked the source) may be if the id of the control changes from one post to another (since it is dynamically built by ASP.NET), normally (in the "raw" asp.net) you can get around it by constructing your JS with something like "<%# FormType.ClientID %>" but I dont know how to get to that same effect in the Saleslogix forms (in the AA)? |
|
|
|
Re: javascript not picking up hidden field values
Posted: 07 Apr 08 11:52 PM
|
Actually on further review the javascript is fine.. I have a form with many panels that are toggled on and off. I was tracking the visbility of panels as they are toggled among other things like a value from the querystring in the textboxes. Thought I could just hide the textboxes, but the hidden textbox values aren't available to C# or javascript. I tried labels, literals, hidden fields.. The labels worked a couple of times, but seem buggy and not working at all now. So I need to store some variables that are currently set onload of the ascx that I can access with C# and javascript as the user fills out the form.. |
|
|
|
Re: javascript not picking up hidden field values
Posted: 08 Apr 08 1:15 PM
|
Steve,
I have seen the same behavior with hidden textboxes so I came to the conclusion that ASP.net doesnt even render them. This may be inaccurate but since I cant access their properties the net result is the same 
I do what you are trying to do on most of my asp.net pages. I put a hidden field on the form tag use this field to communicate with the user: C# sets the property and javascript reads it on form load.
Maybe try putting your hiddenfield directly on the form and not in any panels.
Here is the javascript:
function bodyOnLoad() { if (document.getElementById("hfMessage").value != "") { alert(document.getElementById("hfMessage").value); document.getElementById("hfMessage").value = ""; } }
Here is the form header:
[form id="frmSalesContract" runat="server"] [asp:HiddenField ID="hfMessage" runat="server" /]
Another comment is that I would use the body's onload event and not just inline javascript at the end of the page. You may be doing this but I wanted to mention it in case.
Hope that helps!
Timmus
|
|
|
|
Re: javascript not picking up hidden field values
Posted: 08 Apr 08 1:24 PM
|
The problem ended up being that the hidden field was bound to the form. Not sure why this prevented me from setting the property, probably getting set to nothing after the onload in retrospect.. I actually ended up going with textboxes set to no border with white text. I support your conclusion about hidden fields not getting rendered. I have been living in the lan client too long.. |
|
|
|
Re: javascript not picking up hidden field values
Posted: 08 Apr 08 2:31 PM
|
Steve,
Just to clarify I am not stating hidden fields dont get rendered; controls with their visible property set to false dont get rendered. HiddenFields work flawlessly for us.
Also, what do you mean by "The problem ended up being that the hidden field was bound to the form". Again this works great for us so I am curious what problem(s) you have encountered. Thankfully you have found a work around but I dont believe a work around should be necessary.
Just curious...
Timmus |
|
|
|
Re: javascript not picking up hidden field values
Posted: 08 Apr 08 2:38 PM
|
Bad wording on my part - not hidden fields ( I am still not 100% sure what was going on.. It seem to work then not. Finally when I 'un'bound the field I could set the value.. I am still not 100% clear why it was happening. Its a long trip to build and deploy testing these things.. This was quite a time suck for such a simple issue. |
|
|
|
Re: javascript not picking up hidden field values
Posted: 08 Apr 08 3:45 PM
|
Ahh, I am not developing in the Application Architect. This is a stand alone ASP.net application and I am not using databinding as ASP.net's databinding sucks. So with all the additional variables I would say we are not comparing apples to apples .
Using the Application Architect is most certainly a time consuming endeavor. I trust that Sage is making strides to improve the experience as it is currently very painful.
Thanks Steve!
Timmus |
|
|
|
Re: javascript not picking up hidden field values
Posted: 08 Apr 08 3:51 PM
|
Just to come full circle, I started the form in AA and let slx map the fields. I then compiled and copied the smartpart to a new location then did the rest in VS. I mapped additional fields based on the SLX code. So kind of a hybrid.. but I still had to build/deploy in AA to test changes. Pain in the arse... I wonder if there is an easier way.. |
|
|
|