Hi,
I open an aspx page into the editor. The user change its content and later I want to save it in the same file.
For so I have used a snippet code that I have found in ASP.NET for AJAX 2009 Q1.
I get an error in EditorMatchEvaluator function, with "Match" variable.
Error 1 The type or namespace name 'Match' could not be found (are you missing a using directive or an assembly reference?)
I have added all references as possible but the problem still exist.
Do you know what am I missing?
Thank you in advance.
I open an aspx page into the editor. The user change its content and later I want to save it in the same file.
For so I have used a snippet code that I have found in ASP.NET for AJAX 2009 Q1.
| private bool _contentUpdated = false; |
| private string _editorContent = string.Empty; |
| private string EditorMatchEvaluator(Match m) |
| { |
| _contentUpdated = true; |
| string newContent = m.Groups[1].Value + _editorContent + "</content>"; |
| return newContent; |
| } |
| private void SaveInCurrentFile(RadEditor editor) |
| { |
| try |
| { |
| //read file |
| string physicalFileName = MapPathSecure(this.AppRelativeVirtualPath); |
| FileStream fs = new FileStream(physicalFileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); |
| StreamReader sr = new StreamReader(fs); |
| string pageContent = sr.ReadToEnd(); |
| //update content |
| _contentUpdated = false; |
| _editorContent = editor.Content; |
| MatchEvaluator mEvaluator = new MatchEvaluator(EditorMatchEvaluator); |
| pageContent = Regex.Replace(pageContent, "(<(\\w+):RadEditor[^>]+?ID\\s*=\\s*['\"]?" + editor.ID + "['\"]?[^>]*>[\\s\\S]*?<content>)[\\s\\S]*?</content>", mEvaluator, RegexOptions.IgnoreCase | RegexOptions.Compiled); |
| //update file |
| if (_contentUpdated) |
| { |
| fs.Seek(0, SeekOrigin.Begin); |
| StreamWriter sw = new StreamWriter(fs); |
| sw.BaseStream.SetLength(0); |
| sw.Write(pageContent); |
| sw.Flush(); |
| sw.Close(); |
| } |
| else |
| { |
| sr.Close(); |
| } |
| } |
| catch (Exception) |
| { |
| //"The File Encoding you have provided is not supported!" |
| //"Refresh the screen and try again!" |
| //"Another process or user is using the resource (ascx/aspx file) you are trying to update." |
| //"Check if the ASPNET user (IIS5) / NETWORK SERVICE account (IIS6) has write privileges for this file." |
| } |
| } |
| } |
I get an error in EditorMatchEvaluator function, with "Match" variable.
Error 1 The type or namespace name 'Match' could not be found (are you missing a using directive or an assembly reference?)
I have added all references as possible but the problem still exist.
Do you know what am I missing?
Thank you in advance.