2011-09-16 2 views
0

int를 사용하여 span 및 2 asp 컨트롤을 만드는 사용자 정의 컨트롤을 사용합니다.스팬 스팬 ID 내에서 ASP 컨트롤에 액세스하려면 어떻게해야합니까?

<abc:edf runat="server" ID="testing" ... /> 

내 질문은 어떻게 범위 내에서 span 컨트롤에 액세스 할 수 있습니까?

내가

var test = $get('<%=testing.ClientID %>'); 
alert(test.all.[hard coded client ID of inner asp control].value) 

하여 얻을 수 있지만 분명히 내가 지금이 처리하는 더 좋은 방법이 하드 코드로 클라이언트 ID를 싶지 않아?

+1

http://stackoverflow.com/questions :

public class TestControl : CompositeControl { private TextBox textBox; public string TextBoxClientID { get { return textBox.ClientID; } } protected override void CreateChildControls() { textBox = new TextBox(); textBox.ID = "textBox1"; Controls.Add(textBox); } } 

당신은 당신의 코드 블록에 액세스 할 수 있습니다 그 방법/5666011/retrieve-id-of-server-control-using-jquery는 ASP.Net 4.0에서 기능을 사용하는 것과 같은 몇 가지 아이디어가 있습니다. –

답변

3

당신은 컨트롤이 공용 속성 때문에 등 clientid에 노출 될 수 있습니다 :

<%= TestControl1.TextBoxClientID %> 
관련 문제