문제

I have around 20 labels to update.

In relation to performance and padeload-weight, I choose WebMethods to realize it (Much smaller then updatepanel + timer).

So, how to update a lot of values in the WebMethod?

(My First intention was to access them normaly as I do: lbl1.Text = "1"; lbl2.Text = "2".... but the method is static - no chance).

도움이 되었습니까?

해결책

Create your method something like (choose some more convenient names tho :-)).

public static object MyMethod()
{
    return new {
        Value1 = "Label1Value",
        Value2 = "Label2Value",
        ...
    };
}

And do it in JavaScript like

<script type="text/javascript">
     var myObj = PageMethods.MyMethod();

     document.getElementById('<%=Label1.ID%>').innerHTML = myObj.Value1;
     document.getElementById('<%=Label2.ID%>').innerHTML = myObj.Value2;
     ...
</script>

Ah well, that'd get you started.

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