Rectangle 27 0

c pass list of string to javascript that is sent by asp code behind method?


<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="UpdatePanel1_Load">
    <ContentTemplate>
        <label id="Label_For_Server_Time" runat="server"></label>
    </ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
    $(function () {
        setInterval("__doPostBack('<%=UpdatePanel1.ClientID%>', '');", 1000);
    });
</script>
HtmlGenericControl myDiv1 = new HtmlGenericControl("div")
Response.Write
UpdatePanel1.Controls.Add()
myDiv1.Style["margin-left"]=t.XTrainLocation-8
protected void UpdatePanel1_Load(object sender, EventArgs e)
{
    Label_For_Server_Time.InnerText = DateTime.Now.ToString();
}

in your code behind, you need to add the updatepanel's load handler, which runs when the panel posts back:

Instead of implementing the whole thing, you can use the Asp.Net UpdatePanel to handle partial page rendering for you.

here is a full example of a serverside clock:

here you can see a label that runs at server so we could access it from code behind;

in order to have the content of your UpdatePanel updated every second as you requested, you need to use javascript to call the auto-rendered Asp.Net postback function with the update panel's id as an argument.

note that in your case, instead of calling a response.write you can dynamically clear your update panel and add HtmlGenericControl in it per 'train', or add them only once and update their styling every postback

this is the piece of code responsible for updating the updatepanel every second, or rather 1000 milliseconds. the function __doPostBack() is an asp.net generated function and by calling setInterval we are making the updatepanel post back every second. the $(function (){}); wrapper here only meant to keep the code from executing before DOM fully loads. you tagged your question with jQuery, so i assume its fine with you.

you can clean your panel every time by calling UpdatePanel1.Controls.Clear();

Note
Rectangle 27 0

c pass list of string to javascript that is sent by asp code behind method?


<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnLoad="UpdatePanel1_Load">
    <ContentTemplate>
        <label id="Label_For_Server_Time" runat="server"></label>
    </ContentTemplate>
</asp:UpdatePanel>
<script type="text/javascript">
    $(function () {
        setInterval("__doPostBack('<%=UpdatePanel1.ClientID%>', '');", 1000);
    });
</script>
HtmlGenericControl myDiv1 = new HtmlGenericControl("div")
Response.Write
UpdatePanel1.Controls.Add()
myDiv1.Style["margin-left"]=t.XTrainLocation-8
protected void UpdatePanel1_Load(object sender, EventArgs e)
{
    Label_For_Server_Time.InnerText = DateTime.Now.ToString();
}

in your code behind, you need to add the updatepanel's load handler, which runs when the panel posts back:

Instead of implementing the whole thing, you can use the Asp.Net UpdatePanel to handle partial page rendering for you.

here is a full example of a serverside clock:

here you can see a label that runs at server so we could access it from code behind;

in order to have the content of your UpdatePanel updated every second as you requested, you need to use javascript to call the auto-rendered Asp.Net postback function with the update panel's id as an argument.

note that in your case, instead of calling a response.write you can dynamically clear your update panel and add HtmlGenericControl in it per 'train', or add them only once and update their styling every postback

this is the piece of code responsible for updating the updatepanel every second, or rather 1000 milliseconds. the function __doPostBack() is an asp.net generated function and by calling setInterval we are making the updatepanel post back every second. the $(function (){}); wrapper here only meant to keep the code from executing before DOM fully loads. you tagged your question with jQuery, so i assume its fine with you.

you can clean your panel every time by calling UpdatePanel1.Controls.Clear();

Note