문제

I have this sample below:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

    <script type="text/javascript">
function test(){

if (test.initialized=='undefined'){
    test.initialized = 'true';
    }

alert(test.initialized);

};
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:Button ID="btnPostBack" runat="server" Text="Post back" OnClientClick="test()" />
</asp:Content>

When I click post-back on the page, I found out that the variable initialized -which is defined on the function itself- is loosing its value and becoming 'undefined' again.

Is it possible to keep those static values once they are defined and make them unaffected from any post backs on the page?

도움이 되었습니까?

해결책

이것이 당신의 문제인지 아닌지는 알지 못하거나 첫 번째 / 성을 사용하여 2013 년에는 버그가 있습니다.

그 진행중인 문제. 사용자 이름을 해결할 수있는 이유는 없지만 이름이 지정되지 않은 이유가 될 수 있습니다!

Microsoft에 언급 된 사용자로서 :

디스플레이 이름 속성에 대한 Active Directory Convention은 "성 이름". 마지막과 첫 번째 사이의 쉼표에 주목하십시오 이름.

우리의 로그온 이름은 사람들의 이니셜을 기반으로합니다. 이들은 2, 3, 4 또는 5입니다 문자가 길다.

SharePoint 2013에서는 사람들과 목록에 문제가 발생합니다. 피커와 검색 정제기가 있습니다. 그것은 쉼표에있는 것처럼 보입니다 표시 이름은 목록 구분 기호로 처리됩니다.

그리드 형식으로 사람 필드가있는 목록을 편집 할 때 우리는 이러한 문제가 발생합니다 :

• "성, 이름"을 통해 사람을 입력 할 수 없습니다. 그것은 throw합니다 오류 : "사용자는 존재하지 않거나 독특하지 않습니다" 동료는 "성"이 없으므로 디스플레이에 쉼표가 없습니다. 그 사람들은 문제없이 검증됩니다.

• 다른 행을 채우는 것과 함께 유효성이 검사 된 사람을 복사 할 수 없습니다

• 사람들이 피커를 가진 사람을 찾아서 선택할 수는 없습니다. 검색 결과. 선택 항목은 그리드에서 유효성 검사를 통과하지 않습니다. 그러나 사용자가 존재하지 않는 오류를 던졌습니다. 사람들 피커가 제안했습니다. (우리는 그 사람이 통과한다고 가정합니다 디스플레이 이름을 통해 식별 된 그리드 구성 요소로 사람들 선택 도구에서 문자열 또는 쉼표가있는 고유 이름 속성 잘못 해석되었습니다.)

• 사람의 "성, 이름"과 이름을 입력하십시오. 다른 로그온 초기 (광고의 DN 속성)에 해당합니다. 사람, 다른 사람이 선택됩니다.

• 검색 정제자를 통해 사람 이름은 2 개의 쉼표로 표시됩니다. 1. "성, 이름"

http://social.technet.microsoft.com/forums/en-us/a55569e7-dcf4-41a4-93fb-62adfcicker-and-accounts-with-comma.forum=.forum=. SharePointAdmin

두 가지 해상도가 있습니다.

1 Microsoft에서 제공하는 스크립트를 사용하여 변경합니다.

:

이름, 성

~

이름 이름

http://gallery.technet.microsoft.com / scriptcenter / 71818859-13CA-42F8-99F9-2783F70984C7 /

또는

2이 업데이트를 사용하십시오.

이 누적 업데이트 패키지가 수정 된 문제점

• 디스플레이 이름에 쉼표가 포함 된 사용자에게 작업을 할당 할 때 SharePoint Server 2013 사이트에서는 다음과 같은 오류가 발생합니다. 메시지 :

사용자가 존재하지 않거나 고유하지 않습니다.

http://support.microsoft.com/kb/2825647

또한 Microsoft는 다른 영역을 해결할 때 문제를 해결할 수 없지만 핫픽스가 문제를 해결하는 것처럼 보입니다!

다른 팁

Maybe you want to do something like this. I also think that you are confusing test function with test object.

var initialized = false;
function test(){
    if ( !initialized){
        initialized = true;
    }
};
            alert(initialized); // false
            test();
            alert(initialized); //true

javascript is going to be re-executed on postback as the page reloads (unless you are using update panels).

to preserve a client side value, write the value into an asp hidden field using JS, and don't render the javascript if IsPostBack is true so that it doesn't get overwritten on postback

I think using partial-post back is a way as well.

If it is not possible, only by using Java script I think cookies can be another way as long as they are not turned of by the user.

My feeling is the best way is to design the page in a way that I would not need to store it :)

You could add a hidden field and set the value of this? I think this way it'll be preserved in the viewstate, and you can load its value back into your variable with something like:

var p = '<%=blah.Text%>';

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top