首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

request获取到的不为现阶段传入的id

2013-09-28 
request获取到的不为当前传入的id后台代码public static string userID System.Web.HttpContext.Current

request获取到的不为当前传入的id
后台代码
public static string userID = System.Web.HttpContext.Current.Request.QueryString["UserID"].ToString();
    //public static string userID = "B222EF78-D0E6-4EF5-991B-F96800E56030";
    [System.Web.Services.WebMethod]
    public static int addEvent(ImproperCalendarEvent improperEvent)
    {
        CalendarEvent cevent = new CalendarEvent()
        {
            userid = userID,
            title = improperEvent.title,
            description = improperEvent.description,
            start =System.DateTime.ParseExact(improperEvent.start, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
            end = System.DateTime.ParseExact(improperEvent.end, "dd-MM-yyyy hh:mm:ss tt", CultureInfo.InvariantCulture),
        };

        if (CheckAlphaNumeric(cevent.title) && CheckAlphaNumeric(cevent.description))
        {
            int key = EventDAO.addevent(cevent);

            List<int> idList = (List<int>)System.Web.HttpContext.Current.Session["idList"];

            if (idList != null)
            {
                idList.Add(key);
            }

            return key;

        }

        return -1;

    }

    private static bool CheckAlphaNumeric(string str)
    {

        if (string.IsNullOrEmpty(str))
            return false;
        else
            return true;


    }

js
$(document).ready(function () {
    $('#updatedialog').dialog({
        autoOpen: false,
        width: 570,
        buttons: {
            "更新": function () {
                var eventToUpdate = {
                    id: currentUpdateEvent.id,
                    title: $("#eventName").val(),
                    description: $("#eventDesc").val()
                };

                if (checkForSpecialChars(eventToUpdate.title) || checkForSpecialChars(eventToUpdate.description)) {
                    alert("请正确填写主题,内容.");
                }
                else {
                    PageMethods.UpdateEvent(eventToUpdate, updateSuccess);
                    $(this).dialog("close");

                    currentUpdateEvent.title = $("#eventName").val();
                    currentUpdateEvent.description = $("#eventDesc").val();
                    $('#calendar').fullCalendar('updateEvent', currentUpdateEvent);
                }

            },


            "删除": function () {

                if (confirm("确定要删除工作日志吗")) {

                    PageMethods.deleteEvent($("#eventId").val(), deleteSuccess);
                    $(this).dialog("close");
                    $('#calendar').fullCalendar('removeEvents', $("#eventId").val());
                }

            }

        }
    });

    $('#addDialog').dialog({
        autoOpen: false,
        width: 570,
        buttons: {
            "添加": function () {
                var eventToAdd = {
//                //    id: 1,
//                    userid: '64238E8E-C594-4A93-A242-5812F78E81DC',
                    title: $("#addEventName").val(),
                    description: $("#addEventDesc").val(),
                    start: addStartDate.format("dd-MM-yyyy hh:mm:ss tt"),
                    end: addEndDate.format("dd-MM-yyyy hh:mm:ss tt")
                };
                if (checkForSpecialChars(eventToAdd.title) || checkForSpecialChars(eventToAdd.description)) {
                    alert("请正确填写主题,内容.");
                }
                else {
                    PageMethods.addEvent(eventToAdd, addSuccess);
                    $(this).dialog("close");
                }

            }

        }
    });

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
    

    var calendar = $('#calendar').fullCalendar({
        theme: true,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
        monthNames: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
        monthNamesShort: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
        dayNames: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
        dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
        today: ["今天"],
        firstDay: 1,
        buttonText: {
            today: '今天',
            month: '月',
            week: '周',
            day: '日',


            prev: '上一月',
            next: '下一月'
        },
        eventClick: updateEvent,
        selectable: true,
        selectHelper: true,
        select: selectDate,
        editable: true,
        events: "JsonResponse.ashx?userID="+ uid,

        eventDrop: eventDropped,
        eventResize: eventResized,
        eventRender: function (event, element) {
            element.qtip({
                content: event.description,
                position: { corner: { tooltip: 'bottomLeft', target: 'topRight'} },
                style: {
                    border: {
                        width: 1,
                        radius: 3,
                        color: '#2779AA'

                    },
                    padding: 10,
                    textAlign: 'center',
                    tip: true,
                    name: 'cream'
                }

            });
        }

    });

});

每次弹出对话框插入数据时,id都为以前传入的id而非当前id,在后台设置断点无法进入但会直接跳转到其中调用的addevent插入数据的方法中
[解决办法]
你帖的代码太多了,看完这个代码估计头也痛了。

你先要判断变量有没有传错?如果没有错,一定会有值。估计是变量写错了
[解决办法]
首先你自己得思考一下,然后再问一些技术的问题

热点排行