How do I get the original ID of Content Page Control using JavaScript function?

ACiiD

New Member
In my asp.net web application I am getting the \[code\]Texbox\[/code\]'s ID using JavaScript like below\[code\]<script language="javascript" type="text/javascript">function clearTextBox(textBoxID){ document.getElementById('<% =RVTable.ClientID %>').value = http://stackoverflow.com/questions/15851313/textBoxID; alert(textBoxID.toString());}\[/code\]and I am storing that ID in HiddenField \[code\] <asp:HiddenField ID="RVTable" runat="server" />\[/code\]Then I am retrieving the \[code\]TextBox\[/code\]'s id using the below code in codebehind\[code\] TextBox txtbox = (TextBox)FindControl(RVTable.Value.ToString()); if (txtbox != null) { if (txtbox.ID.ToString() == RVTable.Value.ToString()) txtbox.Text = (string)CheckBoxString.ToString(); }\[/code\]For your reference I am doing all this in the Content PageActually my requirement is that I have a few CheckBoxes and a few Textboxes in my project and one add button. I will check some CheckBox and then click on the textbox where the selected checkbox values has to display. Now if I click the Add button the selected CheckBox's values will be displayed in that TextBox. I am storing Clicked textbox's ID in the hidden Field.Here is my pageLoad code the add OnClick attribute to textbox\[code\]txtRasi1.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi2.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi3.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi4.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi5.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi6.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi7.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi8.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi9.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi10.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi11.Attributes["onclick"] = "clearTextBox(this.id)";txtRasi12.Attributes["onclick"] = "clearTextBox(this.id)";\[/code\]I have achieved solution by using the above codes in a simple asp.net web application (when not using MasterPage).But when I'm trying to use this same code in Content Page, the id of the clicked TextBox is coming like \[code\]ctl00_ChildPageContents_txtRasi3\[/code\] instead of \[code\]txtRasi3\[/code\] which is the original ID of the TextBox.As I mentioned in the above code-behind code, the \[code\]FindControl()\[/code\] did not find the clicked textbox since it gets different ID, \[code\]ctl00_ChildPageContents_txtRasi3\[/code\]. How can I get the original ID \[code\]txtRasi3\[/code\]?I found one more problem also...
IqQvb.jpg
Still txtbox object is null even though I mentioned my TexBox's control ID directly in the \[code\]FindControl()\[/code\] method.
 
Back
Top