Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Pre-Populating a form field from a Query String

  Asked By: Angelique    Date: Feb 22    Category: Sharepoint    Views: 37334

I'm trying to pre-populate a field in a new item form from a value in a query

On the New Item Form, I've changed the ListFormField into a text box, created
the parameter in the Web Part& set it to come from a query string & Set the Text
property of the textbox to '{$RefNum} (which is the name of my query string and
parameter. Now, from the few blogs/posts that I've read, that should work.
However, when I view the page I get

"The 'Text' property of 'asp:TextBox' does not allow child objects."

What have I missed?



9 Answers Found

Answer #1    Answered By: Harihar Sonnad     Answered On: Feb 22

Usually this happens because you're assigning an object to it, rather than
the property  of the object that contains the text.

Answer #2    Answered By: Deven Gajjar     Answered On: Feb 22

could you elaborate a little?

If setting the field  to {$RefNum} doesn't get the value of that parameter,
how would I pull the value out?

Answer #3    Answered By: Latisha Schneider     Answered On: Feb 22

Good point. I read  and replied quickly (as you noted). Is it possible that
the error is coming from another textbox  on the page?

I assume this is a custom form  in SharePoint Designer; what does the control
look like in code view?

Answer #4    Answered By: Nora Maxwell     Answered On: Feb 22

I don't think the error is coming from another text  box as when I remove the
{$RefNum}, the error goes away.

the code for the text box  looks like this:

<asp:TextBox runat="server" id="ff1{$Pos}"
runat="server" id="ff1description{$Pos}" FieldName="Title"
ControlMode="Edit" /></asp:TextBox>

Answer #5    Answered By: Corina Duran     Answered On: Feb 22

Is it completely unreasonable to go with a standard textbox? Instead of
<asp:TextBox /> use <input type="textbox" />

Also, is {$RefNum} really not an object? Are you casting it?

Answer #6    Answered By: Irving Hurley     Answered On: Feb 22

What about that SharePoint:FieldDescription control inside the textbox?
Shouldn't that go after the closing tag?

Answer #7    Answered By: Trevor Davis     Answered On: Feb 22

I will try to use a standard text  box when I'm back in the office & see what
happens. I'm not entierly sure what you mean by casting, or how to tell if
it's an object or not (not being a proper developer).

Regarding your question about the field  description control, this is all
sharepoint designer generated code, so I presume that everything is where it
should be? ... or does SPD get things wrong sometimes?

Answer #8    Answered By: Kristie Hardy     Answered On: Feb 22

SPD can mess things up; see *http://tinyurl.com/2c24hmd* for another
annoying example. In any case, controls shouldn't be inside the textbox  (as
the error message states); remove it and I think you'll see different

Answer #9    Answered By: Shayla Mcbride     Answered On: Feb 22

That's exactly what it was.................

Didn't find what you were looking for? Find more on Pre-Populating a form field from a Query String Or get search suggestion and latest updates.