Micro Focus QTP (UFT) Forums
How to proceed in QTP when all fields are prefixed with ctl00_ContentPlaceHolder1 - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to proceed in QTP when all fields are prefixed with ctl00_ContentPlaceHolder1 (/Thread-How-to-proceed-in-QTP-when-all-fields-are-prefixed-with-ctl00-ContentPlaceHolder1)



How to proceed in QTP when all fields are prefixed with ctl00_ContentPlaceHolder1 - nistalaramesh - 10-12-2013

In my web Application all controls are prefixed as below example:

ctl00$ContentPlaceHolder1$txtAssetNumber
ctl00$ContentPlaceHolder1$txtAssetDesc
ctl00$ContentPlaceHolder1$txtRefAssetNumber

This is a .Net web Application
I am using HP UFT11.5.
Qtp Identifying all text boxes like "ctl00$ContentPlaceHolder1$txtAssetNumber" and even for dropdowns, Radio Buttons, Checkboxes the prefix "ctl00$ContentPlaceHolder1$" comes in place.

The Prefix changes from page to page if the same text box present in different pages.

In Coding developer named the text box as "txtAssetNumber" But runtime the name changes dynamically as above mentioned.
But txtAssetNumber is the actual field name.

Attaching the view source of the page.

Code:
<div class="middlemain">
                        <div class="middleleft">
                            <span id="ctl00_ContentPlaceHolder1_lblAssetNumber_Desc">Asset Number/Desc</span>
                            &nbsp;:<span class="mandetory">*</span>
                        </div>
                        <div class="middleRight">
                            <input name="ctl00$ContentPlaceHolder1$txtAssetNumber" type="text" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$txtAssetNumber\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="ctl00_ContentPlaceHolder1_txtAssetNumber" disabled="disabled" tabindex="1" class="textField" style="width:65px;" />
                            <input name="ctl00$ContentPlaceHolder1$txtAssetDesc" type="text" maxlength="32" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolder1$txtAssetDesc\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="ctl00_ContentPlaceHolder1_txtAssetDesc" tabindex="1" class="textField" style="width:230px;" />
                            <span id="ctl00_ContentPlaceHolder1_RequiredFieldValidator2" style="color:Red;display:none;">*</span>

How can i proceed scripting using OR in QTP ??


RE: How to proceed in QTP when all fields are prefixed with ctl00_ContentPlaceHolder1 - pradeep singh - 10-16-2013

You can use regular expression for name property in OR. For ex:".*txtAssetNumber"