2011-11-01 3 views
2

텍스트를 추가 나는이했습니다 ASP 구문 분석기가 처리하지 않았습니다.

어떻게하면됩니까?

+0

내 눈이 아파요 –

+0

@GlennFerrieLive : 예, 나도. 당신은 더 좋은 길을 가졌습니까? – Tuizi

+0

나는 다른 접근법을 공동 서명 할 것입니다. 의미는 링크를 정의합니다 programatica lly. 효과가있는 희망 –

답변

2

마크 업에서이 작업을 수행하지 마십시오. 현재 서버 컨트롤이 - 당신의 .cs 파일에서이 같은 일을 할 다음에게 ID (예를 들어, ID="NavigationLink"을주고, :

void Page_Load(object sender, EventArgs e) 
{ 
    // I'm guessing that "4" was just an example here, so fill that piece in with a function you can call to create the proper ID. 
    NavigationLink.NavigateUrl = Properties.Resources.Path + Properties.Resources.Article + "?id=4" 
} 

편집 : 나는 믿고있어 당신이 <%$ Resources:Path, Article%>을한다는 말을 그 리소스 파일에 PathArticle 항목을 참조하려고 시도했지만 더 자세히 반영하면 자신이하는 일을 정확하게 알 수 없습니까?

1

코드 숨김 클래스에서 보호 된 함수를 정의하고 태그에서 호출 할 수 있습니다. 이처럼 :

<h3> 
    <asp:HyperLink runat="server" 
     NavigateUrl="<%# GetNavigateUrl(Eval("ID")) %>" <%-- Passing an ID as a parameter for example --%> 
     Text='<%# Eval("title") %>' /> 
</h3> 

코드 숨김

// Again, idObj is just an example. Any info from the data item can be passed here 
protected string GetNavigateUrl(object idObj) 
{ 
    int id = (int)idObj; 
    string urlFromResources = // retrieving the url from resources 
    return urlFromResources + '?ID=' + id; 
} 
0

해보십시오 및 String.format ...이로 다른 언어를 혼합하고 마치

<% =String.Format({0}?id={1}, Request.ApplicationPath, 4) %> 

(자바 스크립트?).

또한 서버 측 컨트롤에 ID를 제공하는 것을 잊지 마십시오.

관련 문제