<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8801525116994016671</id><updated>2024-11-01T04:32:07.094-07:00</updated><category term="CKEditor"/><category term="Corrupt documents"/><category term="File"/><category term="ID"/><category term="Link"/><category term="Office 2007"/><category term="Response.OutputStream.Write"/><category term="fckeditor"/><title type='text'>SargeLog</title><subtitle type='html'>It&#39;s all about the code: C#, ASP.NET, JQuery, Javascript, etc.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sargelog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sargelog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dave Sargent</name><uri>http://www.blogger.com/profile/00161012555379939058</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBHx091-tqBXfJ2KIQE1XDqfRAPMvROB3EEQbh_gAWOnY59H7HW0VzE7mnJhhevN1-z7fSpnBsAHDobfxLZyR_Ln8kq5z_RJkjcsFGyU1r7PatVxyGLjHEnXHhMmB6IQ/s220/GrayscalePic.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8801525116994016671.post-537058743149192047</id><published>2011-03-17T08:22:00.000-07:00</published><updated>2011-03-17T08:22:56.556-07:00</updated><title type='text'>Displaying files in Chrome</title><content type='html'>Form many months I have been having problems with our main site code and certain images and files not being displayed in Chrome properly.  These files where being loaded out of a SQL server with some fairly standard .net code.  &lt;br /&gt;
Turns out Chrome doesn&#39;t like it when you are streaming a file and then use&lt;br /&gt;
Response.Close();&lt;br /&gt;
to close the connection. &lt;br /&gt;
We have a bug open with Google about it, hopefully they fix it.&lt;br /&gt;
Hope this helps others!</content><link rel='replies' type='application/atom+xml' href='http://sargelog.blogspot.com/feeds/537058743149192047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sargelog.blogspot.com/2011/03/displaying-files-in-chrome.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/537058743149192047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/537058743149192047'/><link rel='alternate' type='text/html' href='http://sargelog.blogspot.com/2011/03/displaying-files-in-chrome.html' title='Displaying files in Chrome'/><author><name>Dave Sargent</name><uri>http://www.blogger.com/profile/00161012555379939058</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBHx091-tqBXfJ2KIQE1XDqfRAPMvROB3EEQbh_gAWOnY59H7HW0VzE7mnJhhevN1-z7fSpnBsAHDobfxLZyR_Ln8kq5z_RJkjcsFGyU1r7PatVxyGLjHEnXHhMmB6IQ/s220/GrayscalePic.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8801525116994016671.post-4837202972739034584</id><published>2010-05-26T15:24:00.000-07:00</published><updated>2010-06-03T16:00:13.772-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CKEditor"/><category scheme="http://www.blogger.com/atom/ns#" term="File"/><category scheme="http://www.blogger.com/atom/ns#" term="ID"/><category scheme="http://www.blogger.com/atom/ns#" term="Link"/><title type='text'>CKEditor 3: Properly Getting ID of Link or Image textbox to return URL</title><content type='html'>I&#39;m still hacking away trying to upgrade FCKEditor 2 to CKEditor 3.&amp;nbsp; Today&#39;s problem centered around getting the proper ID for the textbox of either the Link Button or Image Button insert window.&amp;nbsp; Turns out these ID&#39;s are quite random, not unlike how .Net generates ID&#39;s for server controls (unfortunately).&amp;nbsp; Like most things in the CKEditor world, this is quite poorly documented but after many different combinations of searches I finally found &lt;a href=&quot;http://cksource.com/forums/viewtopic.php?f=11&amp;amp;t=15700&quot;&gt;this &lt;/a&gt;board posting which cleared things up.&lt;br /&gt;
I&#39;m reposting my code here so as to help spread the word.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Background:&lt;/b&gt;&lt;br /&gt;
The Link and Image buttons&amp;nbsp; (as well as others) in CKEditor will show a dialog box asking you for a URL.&amp;nbsp; You have the option to set a Browser Server button in one of these box&#39;s in your config file which can point to some kind of file browser, probably some other portion of your system or CMS.&amp;nbsp; The challange is then to return a URL form your code back to the CKEditor window.&amp;nbsp; Normally this is quite easy with something like this.&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;strURL += &quot;javascript:window.opener.document.&quot;;
strURL += &quot;getElementById(&#39;&quot; + strReturnControlID + &quot;&#39;)&quot;;
strURL += &quot;.value=&#39;/&quot; + strPageTitle.Replace(&quot;&#39;&quot;, &quot;\\&#39;&quot;);
strURL += &quot;&#39;; window.close()&quot;;&lt;/pre&gt;Where strReturnControlID would contain the ID of the parent textbox from the querystring that I set in the CKEditor Config for the Browser Server button.&amp;nbsp; Problem is, this ID changes, often with each page reload.&amp;nbsp; Lame.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution: &lt;/b&gt;&lt;br /&gt;
The solution is to use the CKEditor API to do the heavy lifting.&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;strURL += &quot;javascript:window.parent.opener.CKEDITOR.tools.callFunction(&quot;;
strURL += Request.QueryString[&quot;CKEditorFuncNum&quot;].ToString();
strURL += &quot;, &#39;&quot; + strPageTitle.Replace(&quot;&#39;&quot;, &quot;\\&#39;&quot;) + &quot;&#39;, &#39;&#39; ); window.close();&quot;; &lt;/pre&gt;I was quite surprised when this worked the first time!&lt;br /&gt;
The CKEditorFuncNum isn&#39;t something you have to worry about, the CKEditor auto passes the correct value for you. &lt;br /&gt;
Hope this helps someone else, let me know if you need any further clarification.</content><link rel='replies' type='application/atom+xml' href='http://sargelog.blogspot.com/feeds/4837202972739034584/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sargelog.blogspot.com/2010/05/ckeditor-3-properly-getting-id-of-link.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/4837202972739034584'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/4837202972739034584'/><link rel='alternate' type='text/html' href='http://sargelog.blogspot.com/2010/05/ckeditor-3-properly-getting-id-of-link.html' title='CKEditor 3: Properly Getting ID of Link or Image textbox to return URL'/><author><name>Dave Sargent</name><uri>http://www.blogger.com/profile/00161012555379939058</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBHx091-tqBXfJ2KIQE1XDqfRAPMvROB3EEQbh_gAWOnY59H7HW0VzE7mnJhhevN1-z7fSpnBsAHDobfxLZyR_Ln8kq5z_RJkjcsFGyU1r7PatVxyGLjHEnXHhMmB6IQ/s220/GrayscalePic.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8801525116994016671.post-1558053669801354693</id><published>2010-04-16T09:05:00.000-07:00</published><updated>2010-06-03T16:11:24.106-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CKEditor"/><title type='text'>CKEditor 3 Simple Save Button Plug-in</title><content type='html'>&amp;nbsp; In a previous post I was talking about how hard it is in the new CKEditor to override the default behavior of the Save button.&amp;nbsp; By design the Save button will cause the form to post, what I wanted it to do was fire a JavaScript function that would open my Save Dialog.&amp;nbsp; Turns out you have to write a plug-in to do this.&amp;nbsp; There are several posts out on the CKSource website that give some code on how to do this, but none of them where quite what I wanted.&amp;nbsp; So here&#39;s my simple Save plug-in for CKEditor 3.&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Start by creating a folder called ajaxSave in the CKEditor\Plugins folder.&lt;/li&gt;
&lt;li&gt;Create a new JavaScript file called plugin.js in the ajaxSave folder&lt;/li&gt;
&lt;li&gt;Paste the following code: &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: jscript&quot;&gt;(function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var saveCmd =
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; modes: { wysiwyg: 1, source: 1 },
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; exec: function(editor) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; showSaveDialog(); // my custom dialog function for doing the save.&amp;nbsp; Uses JQuery UI
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; };
&amp;nbsp;&amp;nbsp;&amp;nbsp; var pluginName = &#39;ajaxSave&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CKEDITOR.plugins.add(pluginName,
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; init: function(editor) {
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var command = editor.addCommand(pluginName, saveCmd);
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; editor.ui.addButton(&#39;AjaxSave&#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; label: editor.lang.save,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; command: pluginName,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; icon: &quot;/ckeditor/plugins/ajaxsave/save.png&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp; });
})();&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Notice the &lt;br /&gt;
icon: &quot;/ckeditor/plugins/ajaxsave/save.png&quot;&lt;br /&gt;
line?&amp;nbsp; So far I haven&#39;t figured out how to reference the default save icon in the skin file so I had to make my own and store it in the same directory as the plugin.&amp;nbsp; I did this by opening the skin icons.png file I was interested in a chopping out the save icon.&lt;/li&gt;
&lt;li&gt;You have to tell CKEditor to load the plug-in.&amp;nbsp; You can do this in your config section, either during CKEditor creation, or in a custom.js config file you load during CKEditor creation.&lt;br /&gt;
The config property looks like this:&lt;br /&gt;
extraPlugins : &#39;ajaxSave&#39;&lt;/li&gt;
&lt;li&gt;Lastly, you need to reference the plug-in in the toolbar.&amp;nbsp; For example, in my CKConfig.js file that I load during editer creationg I have this &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: jscript&quot;&gt;config.toolbar_Default = [
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; [&#39;AjaxSave&#39;], 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&#39;Cut&#39;, &#39;Copy&#39;, &#39;Paste&#39;, . . . .&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
That&#39;s it.&amp;nbsp; At first it looks quite difficult, but once you wrap your head around all the bits it starts to make sense. &lt;br /&gt;
&lt;br /&gt;
For those interested, I am pasting my function that creates my CKEditor instances.&amp;nbsp; This is a work in process and I&#39;m not even close to being done, but I figured it might help someone out there.&amp;nbsp; I&#39;m using the JQuery adapter to load CKEditor.&lt;br /&gt;
&lt;pre class=&quot;brush: jscript&quot;&gt;// load the CKEDITOR in the given div
function loadCKEditor(Div) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var CSSFiles = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; CSSFiles[0] = &quot;https://designer.wsu.edu/template/css2.aspx?key=&quot; + $(&quot;#hfSiteKey&quot;).val();
&amp;nbsp;&amp;nbsp;&amp;nbsp; CSSFiles[1] = &quot;https://files.ba.wsu.edu/styles/additions&quot; + $(&quot;#hfAdditionsVerNum&quot;).val() + &quot;.min.css&quot;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; CSSFiles[2] = &quot;https://files.ba.wsu.edu/styles/PageEditor_CKEditor.css&quot;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;#&#39; + Div).ckeditor(function() { // this is the callback,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // edMain, edSecondary and edAdditional are public vars at the top of the js file, this will assign them the instance of the editor we just created so I can manipulate it later.&amp;nbsp; Note, I&#39;m creating three different editors by calling loadCKEditor 3 times later on.
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (Div === &#39;edMain&#39;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; edMain = $(&#39;#edMain&#39;).ckeditorGet();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (Div === &#39;edSecondary&#39;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; edSecondary = $(&#39;#edSecondary&#39;).ckeditorGet();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (Div === &#39;edAdditional&#39;) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; edAdditional = $(&#39;#edAdditional&#39;).ckeditorGet();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var e = $(&#39;#&#39; + Div).ckeditorGet();
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; $(window).resize(function() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; var eH = $(window).height() - winHeightSub;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.resize(e.config.width, eH);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; fckCompleteCount++;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (fckCompleteCount == 3)&amp;nbsp; // since this gets&#39; called for each FCKeditor_OnComplete (3 times) only want to load when compleatly done.
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if ($(&quot;#hfIsDraft&quot;).val() == &quot;true&quot;) // there is a draft to load, show the chooser dialog
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // set AutoSave = false so it doesn&#39;t try to save when dialog is open
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; AutoSave = false;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; $(&quot;#divLoadDraft&quot;).dialog(&quot;open&quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; { load(false); } // no draft to load, just load the main page text
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, { // settings
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; customConfig: &#39;/Masterpages/myFCKConfig.js&#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; toolbarCanCollapse: false,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; toolbar: &#39;Default&#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sharedSpaces:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; top: &#39;fckToolBar&#39;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; bodyId: &#39;content&#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; resize_enabled: false,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; contentsCss: CSSFiles,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; extraPlugins : &#39;ajaxSave&#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; height: EditorHeight
&amp;nbsp;&amp;nbsp;&amp;nbsp; });
}

&lt;pre&gt;&lt;/pre&gt;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://sargelog.blogspot.com/feeds/1558053669801354693/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sargelog.blogspot.com/2010/04/ckeditor-3-simple-save-button-plug-in.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/1558053669801354693'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/1558053669801354693'/><link rel='alternate' type='text/html' href='http://sargelog.blogspot.com/2010/04/ckeditor-3-simple-save-button-plug-in.html' title='CKEditor 3 Simple Save Button Plug-in'/><author><name>Dave Sargent</name><uri>http://www.blogger.com/profile/00161012555379939058</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBHx091-tqBXfJ2KIQE1XDqfRAPMvROB3EEQbh_gAWOnY59H7HW0VzE7mnJhhevN1-z7fSpnBsAHDobfxLZyR_Ln8kq5z_RJkjcsFGyU1r7PatVxyGLjHEnXHhMmB6IQ/s220/GrayscalePic.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8801525116994016671.post-8128773377119290675</id><published>2010-04-15T13:56:00.000-07:00</published><updated>2010-06-03T16:12:50.976-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Corrupt documents"/><category scheme="http://www.blogger.com/atom/ns#" term="Office 2007"/><category scheme="http://www.blogger.com/atom/ns#" term="Response.OutputStream.Write"/><title type='text'>Dealing with corrupt xlsx, docx files when reading from SQL Blob</title><content type='html'>I&#39;ve had a bug in my bug tracking system for our CMS for a while now.&amp;nbsp; Basically, any Office 2007 files that where uploaded into our CMS came back as corrupt when downloaded.&amp;nbsp; The short term solution was to have everyone down-convert the docs.&amp;nbsp; I finally got around to fixing this today and wanted to share my results with everyone.&lt;br /&gt;
&lt;br /&gt;
My old code looked like this.&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;do
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; bytesRead = dr.GetBytes(11, readFrom, bytes, 0, bufferSize);
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Web.HttpContext.Current.Response.BinaryWrite(bytes);
&amp;nbsp;&amp;nbsp;&amp;nbsp; readFrom += bufferSize;
}
while (bytesRead == bufferSize);&lt;/pre&gt;&lt;br /&gt;
From my research, it looks like this will work fine for most anything but Office 2007 docs, for whatever reason, those tend to end up being a single byte too long.&amp;nbsp; Of course the other possability is that many things where a single byte too long but their document formats either didn&#39;t care or took care of that extra padding.&amp;nbsp; In any case the solution is to use Response.OutputStream.Write instead of Response.BinaryWrite&lt;br /&gt;
Here&#39;s the new code:&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;byte[] buffer = new Byte[4096];
try
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; long startIndex = 0; //Start of the blob
&amp;nbsp;&amp;nbsp;&amp;nbsp; Stream outputStream = Context.Response.OutputStream;
&amp;nbsp;&amp;nbsp;&amp;nbsp; while ((bytesRead = dr.GetBytes(blobColumnIndex, startIndex, buffer, 0, buffer.Length)) &amp;gt; 0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Verify that the client is connected.
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if (System.Web.HttpContext.Current.Response.IsClientConnected)
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; outputStream.Write(buffer, 0, (int)bytesRead);

&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; // Reposition the start index to the end of the last buffer and fill the buffer.
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; startIndex += bytesRead;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //prevent infinite loop if user disconnects
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; startIndex += 10000;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
catch (Exception ex)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Trap the error, if any.
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Web.HttpContext.Current.Response.Write(&quot;Error : &quot; + ex.Message);
}
finally
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Web.HttpContext.Current.Response.Close();
}&lt;/pre&gt;&lt;br /&gt;
Remember that datareader.GetBytes relies on the datareader being in SequentialAccess mode, ala&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess);&lt;/pre&gt;in SequentialAccess mode you must access the columns in order.&lt;br /&gt;
&lt;br /&gt;
Hope this helps those suffering the same problem.</content><link rel='replies' type='application/atom+xml' href='http://sargelog.blogspot.com/feeds/8128773377119290675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sargelog.blogspot.com/2010/04/dealing-with-corrupt-xlsx-docx-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/8128773377119290675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/8128773377119290675'/><link rel='alternate' type='text/html' href='http://sargelog.blogspot.com/2010/04/dealing-with-corrupt-xlsx-docx-files.html' title='Dealing with corrupt xlsx, docx files when reading from SQL Blob'/><author><name>Dave Sargent</name><uri>http://www.blogger.com/profile/00161012555379939058</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBHx091-tqBXfJ2KIQE1XDqfRAPMvROB3EEQbh_gAWOnY59H7HW0VzE7mnJhhevN1-z7fSpnBsAHDobfxLZyR_Ln8kq5z_RJkjcsFGyU1r7PatVxyGLjHEnXHhMmB6IQ/s220/GrayscalePic.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8801525116994016671.post-173037911391397086</id><published>2010-04-13T11:48:00.000-07:00</published><updated>2010-06-03T16:14:13.901-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CKEditor"/><category scheme="http://www.blogger.com/atom/ns#" term="fckeditor"/><title type='text'>Fighting with CKEditor</title><content type='html'>Trying to upgrade our CMS from FCKEditor 2.x to CKEditor 3.0.&amp;nbsp; Where somethings are easier to do, others . . . not so much.&amp;nbsp; Like overriding the Save button built into the editor for doing AJAX posts.&amp;nbsp; In 2.x it was one line of code (inside the onComplete function).&lt;br /&gt;
&lt;pre class=&quot;brush: jscript&quot;&gt;function FCKeditor_OnComplete(editorInstance)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; // causes save icon to open the custom save dialog
&amp;nbsp;&amp;nbsp;&amp;nbsp; editorInstance.LinkedField.form.onsubmit = showSaveDialog; 
}&lt;/pre&gt;However in 3.x you apparently have to create a new plugin to replace the current save plugin.&amp;nbsp; To be clear, this is lame, poorly documented and&amp;nbsp; . . . well, lame.&lt;br /&gt;
They know this is lame as per this item in the bug tracker.&lt;br /&gt;
&lt;a href=&quot;http://dev.fckeditor.net/ticket/4507&quot;&gt;http://dev.fckeditor.net/ticket/4507&lt;/a&gt;&lt;br /&gt;
but it apparently isn&#39;t lame enough for them to actually roll said fix into the production code.&lt;br /&gt;
&lt;br /&gt;
So, I&#39;m working on a plugin.&amp;nbsp; Stay tuned, I shall conquer this beast and then post the code so others won&#39;t have to suffer such pain.</content><link rel='replies' type='application/atom+xml' href='http://sargelog.blogspot.com/feeds/173037911391397086/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sargelog.blogspot.com/2010/04/fighting-with-ckeditor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/173037911391397086'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8801525116994016671/posts/default/173037911391397086'/><link rel='alternate' type='text/html' href='http://sargelog.blogspot.com/2010/04/fighting-with-ckeditor.html' title='Fighting with CKEditor'/><author><name>Dave Sargent</name><uri>http://www.blogger.com/profile/00161012555379939058</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBHx091-tqBXfJ2KIQE1XDqfRAPMvROB3EEQbh_gAWOnY59H7HW0VzE7mnJhhevN1-z7fSpnBsAHDobfxLZyR_Ln8kq5z_RJkjcsFGyU1r7PatVxyGLjHEnXHhMmB6IQ/s220/GrayscalePic.jpg'/></author><thr:total>0</thr:total></entry></feed>