what is this how to avoid "ctl00"

Posted by Gow.Net under JavaScript on 7/28/2012 | Points: 10 | Views : 3788 | Status : [Member] | Replies : 4
following scrip i am using in asp.ne web application
this code will be write in my master page
 <script type="text/javascript">

function IAmSelected(source, eventArgs) {

$find('"AutoCompleteExtender3 ').set_contextKey(eventArgs.get_value());
$find('"AutoCompleteExtender2 ').set_contextKey(eventArgs.get_value());


}

</script>


<table>

<tr>

<td>

<asp:TextBox ID="txt_city" runat="server"></asp:TextBox>

<asp:TextBoxWatermarkExtender ID="watermark1" runat="server" TargetControlID="txt_city" WatermarkText="Coimbatore"></asp:TextBoxWatermarkExtender>

<asp:AutoCompleteExtender ID="cityautocomplete"

TargetControlID="txt_city"

runat="server"

MinimumPrefixLength="1"

CompletionInterval="10"

EnableCaching="true"

ServiceMethod="GetCompletionList"

OnClientItemSelected="Selectarea"

ServicePath="~/AutoComplete.asmx"></asp:AutoCompleteExtender>

</td>

<td>

<asp:TextBox ID="txt_Search" runat="server" Height="21px" Width="281px"></asp:TextBox>

<asp:AutoCompleteExtender ID="Searchautocomplete"

TargetControlID="txt_Search"

runat="server"

MinimumPrefixLength="1"

CompletionInterval="10"

EnableCaching="true"

ServiceMethod="GetSearchList"

ServicePath="~/AutoComplete.asmx"></asp:AutoCompleteExtender>

<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="txt_Search" WatermarkText="Search Example - ICICI Bank"></asp:TextBoxWatermarkExtender>

</td>

<td>

<asp:TextBox ID="txt_Place" runat="server"> </asp:TextBox>

<asp:AutoCompleteExtender ID="AutoCompleteExtender1"

TargetControlID="txt_Place"

runat="server"

MinimumPrefixLength="1"

CompletionInterval="10"

EnableCaching="true"

ServiceMethod="GetAreaList"

ServicePath="~/AutoComplete.asmx"></asp:AutoCompleteExtender>

<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server" TargetControlID="txt_Place" WatermarkText="Rspuram"></asp:TextBoxWatermarkExtender>
</td>

<td>

<asp:Button ID="btn_Search" runat="server" Text="Go" onclick="btn_Search_Click" />

</td>

</tr>
</table>



when i run my application in IE and view page source means following changes will be occurred

 <script type="text/javascript">

function IAmSelected(source, eventArgs) {

$find('"ctl00_AutoCompleteExtender3 ').set_contextKey(eventArgs.get_value());
$find('"ctl00_AutoCompleteExtender2 ').set_contextKey(eventArgs.get_value());

}

</script>


i am using .net frame work 3.5 anyone please tell me how to solve his auto generation ID

gowthaman8870226416


Responses

Posted by: Maneel on: 7/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
"ct100" means it is clientID generated in HTML which is unique. The unique clientid generated for every control in html which will be series like "ct100_" whatever the control you have in your application will have its own unique clientid. This id will be same in all the browsers we dont have any browser related issues for this. one more advantage by this clientid if you dont get control in javascript we can use this clientId manually to get the control. For example
you are writing like this.....
$find('"AutoCompleteExtender2 ').set_contextKey(eventArgs.get_value());
if you are not getting control by this means you can give manually like this to get the control.....
$find('"ctl00_AutoCompleteExtender2 ').set_contextKey(eventArgs.get_value());

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajkatie on: 8/2/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Hi,

you can avoid this problem if your are using .net framework 4.0 because it has introduce new property called ClientIDMode which have four properties like AutoID,Static,Predictable and Inherit.

For more details each of these, visit http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode.aspx

Rajesh Patel
.Net Trainer(MSCD | MCT | MS)
Brainbench (Asp.Net 4.5 and C# 5.0)

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bhupentiwari on: 8/3/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Set CleinIDmode property to static it will not come.

use framework 4.0

Thanks n Regards
Bhupendra Tiwari

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gow.Net on: 9/11/2012 [Member] Starter | Points: 25

Up
0
Down
how to set Set CleinIDmode property to static .

gowthaman8870226416

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response