Forum Moderators: open
Im pretty sure that you aren't allowed to use FULLSTOPS in variable names in .NET, but my problem is that I have to create a specific form with hidden fields that I wanted to populate from the code behind. The form I have to create contains fieldnames like "cust.email" which is why im having problems turning them into runat="server" fields which are available in my code behind.
1. Anyway can I use fullstops? (I know this is a NO but I cant find any web pages that state it this morning)
2. Can I use fullstops and then reference the fields like [cust.email] or "cust.email", neither of these work but is there something similair?
Cheers
"." on the server side is how you reference an object's methods and properties.
"." also delimits names spaces...(system.web.ui.webcontrols)...so if you try to use them the compiler will look at it say it is incorrect...easy as that.
If you really need to use "." in your id names just don't use asp.net server controls...use standard HTML inputs and then get the values out using Request.form("Cust.Email")
<FORM>
<INPUT name="Field1" type="hidden" value="<%=Property1%>">
</FORM>
Then in the code behind:
Public Property Property1 as string
.....
End Property
Sub Page_Load
Me.Property1 = "My Value"
End Sub
Page.RegisterHiddenField("fieldname","fieldvalue"); This will write the hidden fields. But on postback to get access to the data you have to use the string result =this.Page.Request.Form["fieldname"]; For more info check out the info on MSDN
"Page.RegisterHiddenField"
[msdn.microsoft.com...]
"Request.Form"
[msdn.microsoft.com...]
I wanted to be able to set attributes like the action of the HTML form to be either the external server or our test server. Either way in making the form runat="server" it just submits to itself which isn't what i wanted.
I tried just making the form fields runat="server" as well but this also didn't work.
I have only about 9 fields so using Response.Write i just create the HTML field as the page loads and can change and set strings as i wish giving me a way to change the values as i wanted.
The form is from an external company so we can connect to their servers, its a poor way of doing but thats what they decided.
Cheers for your help!