-1

I currently got a calendar with edit buttons on each date, and once you press on them they send a "setReminder=ID" in the URL field. While the ID is correct, I have no idea how to actually "catch" the ID?

The situation is pretty much as following:

  1. The user clicks on the edit button on the respective date in the calendar
  2. The calendar sets "setReminder=ID-goes-here" in the URL field, as well as opens a form to set the event in
  3. The user inserts a event, hits submit, and the reminder appears in the calendar. On all dates, not just the one they selected, and this is where the problem is.

Currently I've got:

<%               
    var days = DateTime.DaysInMonth(2015, 11);
    var month = 11;
    var year = 2015;
    List<string> dateTimes = new List<string>();
    for (int x = 1; x < 8; x++)
    {
        string dateTime = new DateTime(year, month, x).ToString("dddd") ;
        dateTime = dateTime.Replace(dateTime[0], dateTime[0].ToString().ToUpper()[0]);
        Response.Write("<div class='days visible-lg-inline-block'> <ul> <li>");
        Response.Write(dateTime);
        Response.Write("</li> </ul> </div>");
        dateTimes.Add(dateTime);
    }
    for (int i = 1; i < days; i++)
    {
        Response.Write("<div class='week'>");
        Response.Write("<ul>");
        Response.Write("<li>");    
        Response.Write(i);
%>
<a href='WebForm1.aspx?setReminder=<%= i %>'> <img src='editIcon.png' alt='Set reminder' /> </a>
<%
        Response.Write("</li>");
        Response.Write("</ul>");
        Response.Write("</div>");
    }
    var setReminder = Request["setReminder"];
    if(setReminder != null) 
    {
%>
<h3>Set a reminder/event</h3>
<form method="POST" action="WebForm1.aspx">
    <input type="hidden" name="reminderId" value="25" />
    Event name: <input type="text" name="reminderName" /> <br />
    <button type="submit" name="submitReminder">Set</button> <br />
</form>            
<% 
    }
%>
Shweta Pathak
  • 775
  • 1
  • 5
  • 21
Xariez
  • 759
  • 7
  • 24

1 Answers1

0

If I got it correct, you need to get the value of setReminder from the URL. The setReminder in URL is query parameter, and you can get it's value like this -

In C# you can use QueryString property of HttpRequest class-

string setReminderValue= Request.QueryString["setReminder"];

If you need it in Javascript, you can do it like this

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

as answered here - How can I get query string values in JavaScript?

Community
  • 1
  • 1
Yogi
  • 9,174
  • 2
  • 46
  • 61