10 Answers, 1 is accepted
0
Hi Sammy78,
The easiest way to get the value is to find the HtmlHiddenElement in the page by its id and extract its value. To do this follow this steps:
1. Convert a click step to code
2. Change the code from this:
to this:
Please note that "HttpLocalhost9000HtmlHid" is the page that is currently in use in my test yours will be different. If that page does not contain the hidden element the test step will fail.
Best wishes,
Nikolai
the Telerik team
This scenario is possible. Here is an example:
If we assume that this is the HTML representation of field:
<
input
type
=
"hidden"
id
=
"myHiddenField"
value
=
"MyValue"
/>
The easiest way to get the value is to find the HtmlHiddenElement in the page by its id and extract its value. To do this follow this steps:
1. Convert a click step to code
2. Change the code from this:
// Click 'HtmlTag'
Pages.HttpLocalhost9000HtmlHid.HtmlTag.Click(
false
);
to this:
[CodedStep(@
"GetValue 'myHiddenField'"
)]
public
void
HiddenField_CodedStep()
{
//Get Hidden field by id
var hiddenFieldControl = Pages.HttpLocalhost9000HtmlHid.Get<HtmlInputHidden>(
"id=myHiddenField"
);
var fieldValue = hiddenFieldControl.Value;
}
Please note that "HttpLocalhost9000HtmlHid" is the page that is currently in use in my test yours will be different. If that page does not contain the hidden element the test step will fail.
Best wishes,
Nikolai
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Sammy78
Top achievements
Rank 2
answered on 02 Sep 2010, 01:08 PM
Hi Nikolai,
Thanks for the reply. I will try it out and hopefully get back to you with positive feedback.
Sincerely,
Sam
Thanks for the reply. I will try it out and hopefully get back to you with positive feedback.
Sincerely,
Sam
0

Sammy78
Top achievements
Rank 2
answered on 21 Sep 2010, 03:49 PM
Hi Nikolai,
I was finally able to try out your solution, but my test can't seem to find the hiddenField, but it might have to do with the page definition. Here is the code for the aspx:
And here's the code the I put in the coded_step:
And my log doesn't write.
Thanks for the help
Sam
I was finally able to try out your solution, but my test can't seem to find the hiddenField, but it might have to do with the page definition. Here is the code for the aspx:
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"cphContenuPage"
runat
=
"server"
>
<
div
class
=
"grid_24"
>
<
div
class
=
"clear"
></
div
>
<
div
class
=
"grid_24 H1TitrePage"
>
<
asp:Label
ID
=
"lblTitreH1"
runat
=
"server"
Text
=
"lblTitreH1"
></
asp:Label
>
<
asp:Image
ID
=
"imgBandeau"
runat
=
"server"
CssClass
=
"ccImage"
/>
<
asp:Image
ID
=
"imgDestination"
runat
=
"server"
CssClass
=
"ccImage"
/>
</
div
>
<
div
class
=
"clear"
></
div
>
<
telerik:radscriptmanager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:radscriptmanager
>
<
h2
id
=
"h2Titre"
runat
=
"server"
>Partez l'esprit tranquille !</
h2
>
<
br
/>
<
h5
id
=
"lblPolice"
runat
=
"server"
>NO de Police</
h5
>
<
asp:Label
ID
=
"lblNoPoliceCache"
runat
=
"server"
Text
=
"Label"
Visible
=
"False"
></
asp:Label
>
<
asp:HiddenField
ID
=
"hfNoPolice"
runat
=
"server"
/>
<
uc1:ProtectionsAssures
ID
=
"ProtectionsAssures1"
runat
=
"server"
/>
<
uc2:GrilleRecommandation
ID
=
"GrilleRecommandation1"
runat
=
"server"
/>
<
br
/>
<
table
style
=
"width: 900px;"
>
<
tr
>
<
td
width
=
"80%"
>
</
td
>
<
td
align
=
"right"
valign
=
"top"
width
=
"15%"
>
<
asp:Button
ID
=
"btnRetournerQuoter"
runat
=
"server"
Width
=
"150px"
/>
</
td
>
</
tr
>
</
table
>
</
div
>
</
asp:Content
>
And here's the code the I put in the coded_step:
<CodedStep(
"Click 'Div'"
)> _
Public
Sub
HiddenField_CodedStep()
'Get Hidden field by id
Dim
hiddenFieldControl
As
HtmlInputHidden = Pages.Page_confirmation.
Get
(Of HtmlInputHidden)(
"id=hfNoPolice"
)
Dim
fieldValue
As
String
= hiddenFieldControl.Value
Log.WriteLine(
"Value: "
+ fieldValue)
End
Sub
And my log doesn't write.
Thanks for the help
Sam
0
Hello Sammy78,
Rendered Client Html:
so it is normal the value to be 'null'. May be there is a server or client method for setting the value that is not part of the code you sent?
Anyway I added a 'Value' attribute to your code:
and the test returned the value as it should.(see attachment)
Nikolai
the Telerik team
From the page you've sent I don't see a Value attribute for you "hfNoPolice" field. This hidden field has only two attributes - id and name:
Server:
<
asp:HiddenField
ID
=
"hfNoPolice"
runat
=
"server"
/>
<
input
type
=
"hidden"
name
=
"hfNoPolice"
id
=
"hfNoPolice"
/>
so it is normal the value to be 'null'. May be there is a server or client method for setting the value that is not part of the code you sent?
Anyway I added a 'Value' attribute to your code:
<
asp:HiddenField
ID
=
"hfNoPolice"
runat
=
"server"
Value
=
"myCustomValue"
/>
and the test returned the value as it should.(see attachment)
Nikolai
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Sammy78
Top achievements
Rank 2
answered on 22 Sep 2010, 01:29 PM
The value is set on the load method of the page (and I have checked the source code of the page at runtime and the value is present in the hidden field.
0
Hello Sammy78,
Nikolai
the Telerik team
Is this page on live site?
If it is possible we would like to debug this problem locally because we cannot reproduce it in our test environment.
Nikolai
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0

Morten Røgenes
Top achievements
Rank 1
answered on 22 Sep 2010, 01:52 PM
.NET will probably change the ID of the control to something like '
In the browser, try to 'View source' and see what the ID really is
Content2_hfNoPolice' because the hiddenfield is inside a NamingContainer.In the browser, try to 'View source' and see what the ID really is
0

Sammy78
Top achievements
Rank 2
answered on 22 Sep 2010, 01:55 PM
Sadly, the website isn't online yet. It is on our unit and fonc servers, but outside access is blocked. And I'm not allowed to release too much info at this time.
I was wondering if the problem occured because the hiddenfield is inside a div and I had the wrong path or something. Also, I translated the code to VB, cause well, that's what we use, but maybe I didn't do it correctly.
I was wondering if the problem occured because the hiddenfield is inside a div and I had the wrong path or something. Also, I translated the code to VB, cause well, that's what we use, but maybe I didn't do it correctly.
0

Sammy78
Top achievements
Rank 2
answered on 22 Sep 2010, 01:57 PM
Morten Røgenes: I already checked and I have set the correct ID (and it isn't changed in the generated page source code)
0
Hi Sammy78,
We will really need a sample app reproducing the problem to help you further. Once we have that we will investigate the issue and post back our findings. We can continue communicating in private if you prefer to not share anything publicly.
Best wishes,
Konstantin Petkov
the Telerik team
We will really need a sample app reproducing the problem to help you further. Once we have that we will investigate the issue and post back our findings. We can continue communicating in private if you prefer to not share anything publicly.
Best wishes,
Konstantin Petkov
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items