/    Sign up×
Community /Pin to ProfileBookmark

Accessing Detailsview data data via JavaScript

I have a page with a detailsview containing a number of template fields, displaying data in asp:text boxes. I now want to use JavaScript to take the values and pass them back to the parent/opening window, but I’ve hit a few issues.

The detailsview is called detailsview1 and the text box holding the data is called txtFinalFname. I am then trying to access the value with

[B]document.form1.DetailsView1.txtFinalFname.value[/B]

but getting a JavaScript error “[I]document.form1.DetailsView1.txtFinalFname is null or not an object[/I]”.

How can I gain access to this data to pass it back to the parent window?

Thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisApr 11.2007 — You have one too many objects in your statement. There can't be that many names. It should only bedocument.formName.textBoxName.value
Copy linkTweet thisAlerts:
@TheFlashauthorApr 11.2007 — I tried that, but it gives me the error [I]document.form1.txtFinalFname is null or not an object[/I]

Even though it is declared in my markup exactly as below:


[CODE]
<asp:TemplateField HeaderText="FNAMES" SortExpression="FNAMES">
<EditItemTemplate></EditItemTemplate>
<InsertItemTemplate> </InsertItemTemplate>
<ItemTemplate>
<asp:TextBox ID="txtFinalFname" runat="server" Text='<%# Eval("FNAMES") %>'></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>[/CODE]
Copy linkTweet thisAlerts:
@gil_davisApr 11.2007 — I believe you are confusing server side things with client side things. Show the client results of your posting. That is where the javascript runs.
×

Success!

Help @TheFlash spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...