示例#1
0
 [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")] // it is being validated
 public void AddJavascriptProtocolAttribute(HtmlTextWriterAttribute key, JScriptString jscript)
 {
     FramesetUtil.ValidateNonNullParameter("jscript", jscript);
     this.mHtmlTextWriter.AddAttribute(key, jscript.ToJavascriptProtocol(), false);
 }
示例#2
0
        /// <summary>
        /// Allow application to process posted data. 
        /// </summary>
        public bool ProcessPostedData(
            LearningSession session, HttpRequest request, Dictionary<string, HttpPostedFile> fileCollection)
        {
            // Verify that posted files map to files that actually exist. 
            HttpFileCollection files = request.Files;
            StringBuilder messageBuffer = new StringBuilder();
            bool firstError = true;
            foreach (string fileId in files)
            {
                HttpPostedFile postedFile = files[fileId];
                string filename = postedFile.FileName;

                // If contentLength == 0 and fileName == emptyString, then this is probably a posting after
                // the initial file posting. (For instance, to remove the file.) This is a valid file and is added to the 
                // collection.
                // If the contentLength == 0 and fileName != emptyString, then user is trying to attach a file
                // that has no contents. This is not allowed.
                if ((string.IsNullOrEmpty(filename) && (postedFile.ContentLength == 0))
                    || (!string.IsNullOrEmpty(filename) && (postedFile.ContentLength > 0)))
                {
                    fileCollection.Add(fileId, postedFile);
                }
                else
                {
                    // This is not a valid file.
                    if (firstError)
                    {
                        messageBuffer.Append(
                            Localization.GetMessage("CON_AttachedFileDoesNotExistHtml"));
                        messageBuffer.Append("\r\n<br><br><ul>\r\n");
                        firstError = false;
                    }
                    messageBuffer.AppendFormat("<li>{0}</li>", HttpUtility.HtmlEncode(filename));
                }
            }

            if (!firstError)
            {
                messageBuffer.Append("</ul><br>");
                messageBuffer.Append(Localization.GetMessage("CON_FileAttachmentErrorEndHtml"));

                // Add information for the 'Continue' link
                JScriptString js =
                    new JScriptString(
                        ResHelper.FormatInvariant(
                            "API_GetFramesetManager().DoChoice(\"{0}\");",
                            FramesetUtil.GetStringInvariant(session.CurrentActivityId)));
                messageBuffer.AppendFormat(
                    CultureInfo.CurrentCulture,
                    "<br><br><a href='{0}' >{1}</a>",
                    js.ToJavascriptProtocol(),
                    HttpUtility.HtmlEncode(Localization.GetMessage("HID_ReloadCurrentContent")));

                this.RegisterError(
                    Localization.GetMessage("CON_FileAttachmentErrorTitleHtml"),
                    messageBuffer.ToString(),
                    false);
            }

            return true;
        }
示例#3
0
 [SuppressMessage("Microsoft.Design", "CA1062:ValidateArgumentsOfPublicMethods")]    // it is being validated
 public void AddJavascriptProtocolAttribute(string name,
     JScriptString jscript)
 {
     FramesetUtil.ValidateNonNullParameter("jscript", jscript);
     m_htmlTextWriter.AddAttribute(name, jscript.ToJavascriptProtocol(),
         false);
 }