| Sometimes we need to customize DataView Webparts (DVWP) in the Sharepoint Designer. there are to many cases, one of these cases is always showing the Filter Toolbar. to do this: |
| 1. Go to the <xsl:template name="dvt_1.toolbar"> template |
| 2. at the end of this template you find a if statment |
| <xsl:if test="$dvt_adhocmode = 'filter'" ddwrt:cf_ignore="1"> </xsl:if> |
| delete this statement and that is all |
Thanks, Mohammed AlShafe'i |
Showing posts with label Sharepoint 2007. Show all posts
Showing posts with label Sharepoint 2007. Show all posts
Monday, April 12, 2010
How to show the Filter Toolbar always on for DataView
Tuesday, February 23, 2010
Ajax second postback not working in Sharepoint in UpdatePanel
| We have one problem in work, we spend with that a day without any solution, all we found cause some another problem. This is what help us when the page is not making second postback in update panel when the first postback is fired by element in UpdatePanel and refresh only update panels on the page. |
Taken from Mike Ammerlaan's Blog |
Windows SharePoint Services JavaScript has a “form onSubmit wrapper” which is used to override the default form action. This work is put in place to ensure that certain types of URLs, which may contain double byte characters, will fully work across most postback and asynchronous callback scenarios. However, if your scenarios do not involve double byte character URLs, you may successful disable this workaround and gain the ability to use ASP.NET AJAX UpdatePanels. |
To do this, you may need to register a client startup script which disables this workaround, in addition to resetting the default form action: |
<script type='text/javascript'> _spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true; </script> |
This script may be directly embedded in the page, or could be emitted by a control that uses the UpdatePanel. The following is an example of a very simple method which will fix this issue: |
Private Sub EnsureUpdatePanelFixups() If Me.Page.Form IsNot Nothing Then Dim formOnSubmitAtt As String = Me.Page.Form.Attributes("onsubmit") If formOnSubmitAtt = "return _spFormOnSubmitWrapper();" Then Me.Page.Form.Attributes("onsubmit") = "_spFormOnSubmitWrapper();" End If End If ScriptManager.RegisterStartupScript(Me, GetType(UpdatePanel), "UpdatePanelFixup", "_spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;", True) End Sub |
Thanks, Mohammed AlShafe'i |
Wednesday, February 10, 2010
adding users to sharepoint group programmatically
When I was working on form authunticated portal site in sharepoint 2007, I need to add users to sharepoint group programmatically, all what we need is the following: |
Dim membershipUser As MembershipUser Dim membershipStatus As MembershipCreateStatus membershipUser = Membership.CreateUser( pUsername, pPassword, pEmail, pSecurityQuestion, pSecurityAnswer, True,membershipStatus) ' after creating user, call _addUserToGroup() method using SPSecurity.RunWithElevatedPrivileges(AddressOf ) SPSecurity.RunWithElevatedPrivileges(AddressOf _addUserToGroup) Private Sub _addUserToGroup() Dim site As New SPSite("http://localhost:1200") Dim web As SPWeb = site.OpenWeb() Dim spUser As SPUser web.AllowUnsafeUpdates = True ' call EnsureUser method and pass user name with Membership Provider Name like the following row spUser = web.EnsureUser("AspNetSqlMembershipProvider:" + txtUsername.Text) web.SiteGroups("myCustomGroupName").AddUser(spUser) End Sub |
| Thats all |
| Thanks, Mohammad AlShafe'i |
Thursday, January 7, 2010
Error: A file or folder name contains an invalid character
| When I was trying to deploy a ListDefinition using CTP release of VSeWSS 1.3 for Visual Studio 2008, I got the following error: | ||
| A file or folder name contains an invalid character | ||
This message means: One or more file contains invalid character, but all my soultion files are not contain any invalid character, so after I search I found the Name of ListDefinition contains an invalid character on ListDefinition.xml file, to solve this error just remove this character | ||
![]() | ||
Note: Special character are not allowed in the value of Name in the ListTemplete inside the XML File because when the user trying to deploy the solution. The system will generate a folder with this value, and you know the speacial characters are not allowed in folder or file name | ||
| Thanks, Mohammad AlShafe'i |
ERROR: Unable to load one or more of the requested types
| When I was trying to deploy a web part using CTP release of VSeWSS 1.3 for Visual Studio 2008, I got the following error: |
| VSeWSS Service Error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information |
The solution: I've found the following steps solving this error, here are the steps: 1. Add the All referenced assemblies to the GAC 2. Restart IIS 3. Clean the project in Visual Studio 4. Redeploy your solution again, Then everything will work. |
Thanks, Mohammad AlShafe'i |
Tuesday, December 29, 2009
Failed to load expression host assembly error in a SharePoint web part
I was writing a custom Reporting local report(Microsoft Report rdlc) and everything is working fine,but when I placed it in a SharePoint Web Part, I got this error: |
Failed to load expression host assembly. Details: Could not load file or assembly 'expression_host_31f4d73d84764f4b9a7332f3673bdf0b, Version=10.8.30729.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to grant permission to execute. (Exception from HRESULT: 0x80131418) |
This was fixed by setting the ExecuteReportInCurrentAppDomain property like so: |
| reportViewer1.LocalReport.ExecuteReportInCurrentAppDomain (System.Reflection.Assembly.GetExecutingAssembly().Evidence); |
Thanks, Mohammed AlShafei |
Sunday, December 27, 2009
Converting Web User Control to Web Part in Sharepoint 2007
Many of web part have complex design, of-course we can create this web part by using code-behind code. In other words, creating the controls dynamically, Take a look at this sample web part: |
Protected Overloads Overrides Sub CreateChildControls() MyBase.CreateChildControls() Dim btnShowMessage As New Button() btnShowMessage.Text = "show Message" AddHandler btnShowMessage.Click, AddressOf btnShowMessage_Click Me.Controls.Add(btnShowMessage) End Sub Private Sub btnShowMessage_Click(ByVal sender As Object, ByVal e As EventArgs) Dim lbl1 As New Label() lbl1.Text = "Hello Guest" Me.Controls.Add(lbl1) End Sub |
so if we want to create complex web part (I mean web part contains many controls) this way will take a lot of time and efforts, so I found another way to create a simple or complex web part, after researching, anyway here are the steps: 1) Create your Web User Control. You have the option on how you create it, but in my part, I create it using ASP.NET 2.0 IDE. What I usually did is I create a blank page, then I add a new item which is Web User Control. Take note to uncheck the option which separate your code in a separate file. 2) Design your Web User Control (ascx), from its physical design to its logic coding. 3) compile the solution 4) drag and drop the solution DLL in \windows\assembly 5) browse the DLL inside the assembly folder the right click and select properties 6) Copy the Public Key Token its look like e3dc1ba93544f2e9 7) open ascx file and insert the following line at the end of Inherits property. , NameSpace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e3dc1ba93544f2e9 8) now after pasting the code the new page register tage will be like this <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="MyUserControl.ascx.vb" Inherits="MyTestSolution.MyUserControl, MyTestSolution, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e3dc1ba93544f2e9" %> 3) Copy the modified ascx file to this directory: c:\inetpub\wwwroot\wss\VirtualDirectories\2222\wpresources Where: 2222: the number of port that your site using wpresources: you can use any other folder. 4) Write the following code for adding your web user control file in your .vb file: |
Protected Overrides Sub CreateChildControls() MyBase.CreateChildControls() dim objUserControl as Control objUserControl= Page.LoadControl("~/wpresources/MyUserControl.ascx") Me.Controls.Add(objUserControl) End Sub |
With Speacial Thanks to Mr. Moutasem Al-awa for his assistance |
Subscribe to:
Posts (Atom)
