Using the SharePoint API
February 20th, 2006 // 5:18 pm @ Amar
One of my articles on using the SharePoint API to create Areas programatically, has been published on DevX. Am a bit late in sending the link, but for those interested, check it out at http://www.devx.com/dotnet/Article/22387.
Posted at DotNetJunkies on Tuesday, November 23, 2004 6:33 AM
Category : SharePoint
Solution to ASP.NET, Javascript value modification problem
February 20th, 2006 // 4:14 pm @ Amar
Sorry for being late. Was tied up in work. So lets start where I left off before. The main problem which I found was that if the ASP.NET button was clicked, and I wanted to run some client side Javascript to update the values of hidden form elements and get the updated values on the postback event handler for that same button, it ignored all the changes javascript made and did not reflect to the code behind. My target was to somehow reflect the changes to the values to the back end.
The solution was not a very elegant one, and I am sure there has to be a different solution to this. But at least it works and gets the job done.
What I did was that I changed by ASP Button in page B to a LinkButton. I assigned blank text to it so effectively making a hidden link button.
<A href=”javascript:SendMail();”>Send Mail</A>
<asp:linkbutton id=SendMail runat=”server”></asp:linkbutton>
This enabled me to call a Javascript when the button was clicked, and also allowed me to have a code behind event handler for the link button click. As the link button is effectively hidden and hence cannot generate an event for the link button click on the back end, we have to raise this event manually in order for this code to work.
The next step would be to implement the SendMail() javascript function.
<script language=”javascript”>
function SendMail()
{
// save the values of the hidden variables from page A
// to the hidden variables in page B
// then call a postback with the id of our SendMail link button
__doPostBack(’SendMail’,’’);
}
This enables the javascript to store the value to the hidden variables first and then call a manual postback which would now take the new updated values and reflect it on the code behind. Effectively the user only has to click one button, which would first call a Javascript, change the values of the hidden form fields, and then do a postback with the new values reflected at the code behind.
Posted at DotNetJunkies on Wednesday, November 17, 2004 6:50 AM
Category : dotNet
ASP.NET Javascript value modification problem 2
February 20th, 2006 // 4:04 pm @ Amar
continued from my previous post …
I guessed as .NET viewstate is managed mostly using Javascript and GET / POST, there should be some way by which I can signify my hidden variables as dirty or refresh the viewstate to reflect the value changes by Javascript, before it is sent to the backend when the Send Message button is clicked. But no avail. I could not find any way to refresh or resync the viewstate using Javascript. I guess that should be because Viewstate is managed on the server so maybe we cannot modify it from the client and ask the server to resync with it.
So second approach, was to try to somehow add the values to a post queue. As new updated values will be send using a standard POST and ASP.NET will sync and update the ViewState internally. So that instead of accessing using ViewState, I can maybe access the updated Javascript values from the backend page using the old Request.Form method. But no avail. Still did not work.
Another idea was to create dynamic textboxes thru Javascripts, when the SendMail button is clicked and fill it with the value and then access them using Request.Form from the backend. But still the new values were not reflected.
Posted at DotNetJunkies on Tuesday, November 09, 2004 1:20 PM
Category : dotNet
ASP.NET, Javascript value modification problem 1
February 20th, 2006 // 4:02 pm @ Amar
While solving one particular case in a SharePoint webpart, I came across a very queer problem in ASP.NET Postback and Viewstate handling. Let me declare the scenario in detail :
I have a page A which has some values in hidden variables of type HtmlControls.HtmlInputHidden.
I popup a page B from page A using javascript window.open. Page B has a button called Send Mail which would send a mail to some recipients. The recipients list has to come from page A.
The standard way of passing data from one window to a javascript popup is querystring, but that is something which is not wanted. It has to work without querystring data passing, and as it is in SharePoint sessions are disabled by default, and hence passing by session is also not an option.
So the only option, is to keep a few hidden variables in page B, read the values from page A using window.opener from Javascript in page B, set the values of the hidden variables in page B, and then on click on Send Mail, access the hidden variables and send a mail using ASP.NET.
The funny problem, is that I can read the values from page A, using javascript. I can also set the values to the hidden variables ( verified by using and alert and checking the value of the hidden variable after it is set ), but as soon as I click Send Message, and try to access the value of the hidden variables from the backend ASP.NET code, the values set using Javascript are lost. On examination, the Viewstate seems to ignore the changes made to the Javascript, if the controls are hidden and does not pass it to the backend.
If the controls are like ASP.NET Textboxes, it works properly, but if they are hidden, again the same problem as above occurs. So definitely it not something exclusive for non .NET Controls.
More on this later on how I solved it when I take my next break
Posted on DotNetJunkies at Tuesday, November 09, 2004 1:12 PM
Category : dotNet
O/R Mapping
February 20th, 2006 // 3:34 pm @ Amar
While doing a research on O/R Mapping and what exactly it is, I came across an excellent post by Frans Bouma at http://weblogs.asp.net/fbouma/archive/2004/10/09/240225.aspx . A excellent piece and explained in a very practical way.
A must read for anyone who uses ADO and database access in the Microsoft world which unfortunately simply ignores these fantastic concepts to work with data applications. Will definitely broaden up your view and give you a new perspective to your application design.
Posted at DotNetJunkies on Tuesday, October 19, 2004 2:26 PM
Category : Miscellaneous
Configuring Word Automation
February 20th, 2006 // 3:32 pm @ Amar
I found some of these links valuable in trying to configure the server to support word automation.
INFO: Considerations for Server-Side Automation of Office
http://support.microsoft.com/kb/257757/EN-US/
How To Configure Office Applications to Run Under the Interactive User Account
http://support.microsoft.com/default.aspx?scid=kb;EN-US;288366
How to configure Office applications to run under a specific user account
http://support.microsoft.com/default.aspx?scid=kb;EN-US;288367
How to configure Office applications for automation from a COM+/MTS package
http://support.microsoft.com/default.aspx?scid=kb;EN-US;288368
Posted at DotNetJunkies on Wednesday, October 13, 2004 4:41 PM
Category : Miscellaneous
Word Automation Code
February 20th, 2006 // 3:30 pm @ Amar
Here
Word.Application wrdApp;
Word._Document wrdDoc;
object oFalse = false;
object oTrue = true;
Word.MailMerge wrdMailMerge;
// Create an instance of Word
wrdApp.Visible = false; // Open the template document.
string TemplateFile = TemplateFilePath + selectedTemplate;
object oFile = Server.MapPath(TemplateFile); wrdDoc = wrdApp.Documents.Open(ref oFile, ref oMissing,ref oTrue, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
wrdDoc.Select();
wrdMailMerge = wrdDoc.MailMerge;
object oSql = “Select * from “ + viewName + ” where Account <> ‘NULL’”;
string ODCFile = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["ODCFile"]); wrdDoc.MailMerge.OpenDataSource(ODCFile,ref oMissing,ref oMissing,ref oFalse,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oSql,ref oMissing,ref oFalse,ref oMissing);
wrdMailMerge.SuppressBlankLines =
true;// Perform mail merge.
wrdMailMerge.Execute(ref oFalse); if(wrdDoc != null)
{
wrdDoc.Saved =true;
wrdDoc.Close(ref oFalse,ref oMissing,ref oMissing);
}
if(wrdApp != null){
wrdApp.Quit(ref oFalse,ref oMissing,ref oMissing);
}
// Release References.wrdMailMerge = null;
wrdDoc = null;
wrdApp = null;
Posted at DotNetJunkies on Wednesday, October 13, 2004 4:35 PM
Category : Miscellaneous
Blog Configuration progress
February 20th, 2006 // 3:21 pm @ Amar
I have decided to halt the configuration process till I hear something back from Yahoo about the permalinks not working. Lets see what they say.
Will be migrating content from my other blogs to this blog next. Instead of migrating all the posts, I will try and copy paste selected posts.
Category : General
WordPress problems on Yahoo
February 17th, 2006 // 1:02 pm @ Amar
I am back to my original blog settings after undoing all I did for the permalink and tags. Seems like, Yahoo is not liking me to edit my .htaccess file using wordpress. It keeps reverting it back to blank. So I am unable to set a url rewrite for category pages, and yahoo gives a page not found error if I choose any format of permalink except the default one. So for now I have rolled back to the default permalink structure which I am not very happy about.
Ultimate Tag warrior is also not working properly. On a force reinstall, it gives Access denied for user ‘
Maybe it is just a wordpress bug or something else. But will wait a bit till I decide what to do. Will send another mail to Yahoo Hosting now.
Category : General
Configuring WordPress – Templates, Plugins, Themes, Services – Part 1
February 16th, 2006 // 8:02 pm @ Amar
As I sit and try to configure my blog, I am getting a reintroduction to blogging. A lot has changed since I created the DotNetJunkies blog on September 13, 2004. So I am re-educating myself to blogging and finding everything very fascinating and confusing. I have decided to write about my blog configuration as I carry on experimenting, trying to get my blog exactly as I want. So here goes.
Till so far, I installed WordPress 2.0 blog on Yahoo hosting. Installation was painless and really very simple. I did not keep the blog mapped to my root site, but close a folder, amargalla.com/blog hence keeping my main site free for other development in the future.
One of the first things I did was set the blog’s name and tagline. Well, not very happy about it, but will change it soon to suit the theme of this blog. Next I tried on various templates, but did not like any of the ones which come with WordPress. A quick search on Google revealed lots of themes. ( On a site note, just realised while typing google, I need a plugin or a setting if it exists, to automatically turn some keywords to links on my posts ). Anyways, so I have kept the theme selection for later as it can be changed anytime. I did like Bloxpress a lot as it is very similar to SharePoint which is my main area of work as of now. It is in beta and still has some bugs, so I intend to hold on for a bit before trying it out.
Category : Blogging