如何使用RegisterStartupScript传递查询字符串?

时间:2014-08-07 14:30:25

标签: c# javascript jquery asp.net registerstartupscript

我的代码背后有这个:

ScriptManager.RegisterStartupScript(this, typeof(string), Guid.NewGuid().ToString().Replace("-", ""), "window.setTimeout(\" $('#" + calendar.ID + "').fullCalendar({header: {left: 'prev,next today',center: 'title',right: 'month,agendaWeek,agendaDay'},aspectRatio: 2.2,editable: true,events: " + sJSON + ", eventClick: function(event) { OpenModal('Novo Compromisso','100%','500px','/agenda/form.aspx?compromissoid=event.id');}});\",100);", true);

它获取一些数据并加载日历的事件属性。在eventClick上我想访问event.id来打开一个模态窗口并编辑事件。但是查询字符串被设置为“event.id'字面上。

我检查了event.id是否有值。它导致它出现在alert()函数中,如下所示。

ScriptManager.RegisterStartupScript(this, typeof(string), Guid.NewGuid().ToString().Replace("-", ""), "window.setTimeout(\" $('#" + calendar.ID + "').fullCalendar({header: {left: 'prev,next today',center: 'title',right: 'month,agendaWeek,agendaDay'},aspectRatio: 2.2,editable: true,events: " + sJSON + ", eventClick: function(event) { alert(event.id); OpenModal('Novo Compromisso','100%','500px','/agenda/form.aspx?compromissoid=event.id');}});\",100);", true);

那么,我如何使用event.id值作为我的查询字符串?

2 个答案:

答案 0 :(得分:2)

在您的OpenModal电话中,更改您的网址' /agenda/form.aspx?compromissoid = event.id'对此:' /agenda/form.aspx?compromissoid =' + event.id

    ScriptManager.RegisterStartupScript(this, typeof(string), Guid.NewGuid().ToString().Replace("-", ""), "window.setTimeout(\" $('#" + calendar.ID + "').fullCalendar({header: {left: 'prev,next today',center: 'title',right: 'month,agendaWeek,agendaDay'},aspectRatio: 2.2,editable: true,events: " + sJSON + ", eventClick: function(event) { alert(event.id); OpenModal('Novo Compromisso','100%','500px','/agenda/form.aspx?compromissoid=' + event.id);}});\",100);", true);

答案 1 :(得分:0)

如果你正在获得event.id,那就像使用它一样使用degraissoid ='+ event.id +''

ScriptManager.RegisterStartupScript(this, typeof(string), Guid.NewGuid().ToString().Replace("-", ""), "window.setTimeout(\" $('#" + calendar.ID + "').fullCalendar({header: {left: 'prev,next today',center: 'title',right: 'month,agendaWeek,agendaDay'},aspectRatio: 2.2,editable: true,events: " + sJSON + ", eventClick: function(event) { alert(event.id); OpenModal('Novo Compromisso','100%','500px','/agenda/form.aspx?compromissoid='+event.id+'');}});\",100);", true);