How to pass a Querystring using Registerstartupscript on Asp.net?

Asked

Viewed 327 times

2

I have this code in my code Behind:

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);

It takes some data and loads the property of full Legend. In eventClick I want to access the value of Event.id to open a modal window and edit the event. But the value of querystring is being assigned as 'Event.id' literally.

I checked the value of Event.id to see if there was something there. The value exists because it appears in the Alert() function as seen below:

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);

So, how can I use the value of Event.id as value for querystring?

1 answer

1

If anyone else is suffering from this, here’s the answer they gave me in the English OS.

In the Openmodal call, change the url '/agenda/form.aspx? compromissoid=Event.id' to: '/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);

Free translation of this link: https://stackoverflow.com/questions/25185168/how-to-pass-a-querystring-using-registerstartupscript/25185301#25185301

Rookie mistake of mine...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.