Passing query string parameters to Visual Web Parts?

Does anyone know how to get the parameters from a query string to a Visual Web Part?
Dan Marth

Hi,
you can read the query string parameter from the code behind using:
Request.QueryString["YourParam"];
You can also use Javascript or jQuery:
http://archive.plugins.jquery.com/project/query-object
http://javascript.about.com/library/blqs1.htm
HTH!
Regards, Sjoukje
Web: http://sjoukjezaal.com | LinkedIn:
http://www.linkedin.com/in/sjoukjezaal | Twitter:
@SjoukjeZaal
Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you.

Similar Messages

  • How to pass query string parameters in list ?

    Hi,
    I have a "Links list" it contains the columns "Empname", "Description" and "Susped/resume" .Here Admin enters the records. When admin enter 'suspend' in "suspend/resume" column it will navigate to "suspend
    page" similarly if enter 'resume' it will navigate to resume page.
    So How I have to set the suspend/resume column by using query string parameter? (dont use hyperlink)
    (We are completely developing my project by using out of box  )
    Appreciate if any one help.
    Thank you.

    Hi,
    It will be easier for others to research on your requirement if you can provide more details about your requirement.
    What is the reason of not using a hyperlink field type? As with hyperlink, we can navigate to other pages easily.
    If you want to use other field type, we will need to write some code(JavaScript) to meet your requirement.
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Using Query String Parameters with Session Scoped bean

    I would like to pass query string parameters from a product page (user clicks on a specific product commandLink) that is request scope to a details page that is session scoped.
    The problem is that the session scoped page only handles the first request. If you view the details of a product and then navigate back to the product page and choose another product ... the details page will not handle the new query string parameters and display the details for the first product chosen.
    Is there a way to make the session scoped bean recognize the query string parameters past the first request?

    I was able to replicate this problem with a very simple app that performs a redirection... just like the real app. Here's the simple app that I put together:
    From request scope page:
    <f:view>
             <h:form>
               <h:commandButton value="Link 1" action="#{reqbean.Link1}"/>
               <br/><br/>
              <h:commandButton value="Link 2" action="#{reqbean.Link2}"/>
            </h:form>
           </f:view>
    From request scope bean:
    public String Link1() throws IOException
        // Add event code here...
        //redirect the user
        FacesContext.getCurrentInstance().getExternalContext().redirect("untitled2.jspx?p=1");
        return null;
      public String Link2() throws IOException
        // Add event code here...
        //redirect the user
        FacesContext.getCurrentInstance().getExternalContext().redirect("untitled2.jspx?p=2");
        return null;
      }At this point... I put a println in the constructor of the session scoped bean because this is where I want to get the query string params. The constructor only gets called the first time a redirect is performed.

  • How to display alert message box in sharepoint 2013 visual web part?

    Hi,
    I am developing a visual web part which submits data to the list. Once it submits the data, I should convey to the user that the data has been submitted successfully.
    I tried using clientScript.RegisterStartUpScript etc, but, none of them are working. It is not throwing any error , but pop up is not getting displayed.
    Preferrably, I would like to call this alert message from cs page, because, I will be using it in several places.
    Please help me.!
    Thanks in advance.
    Hepsi

    Hepsi, 
    Step 1. On the Page_Load - This way you can pass parameters. Try this
    btn.Attributes.Add(
    "onclick", string.Format("return openSPPopup('{0}?{1}={2}', '{3}')", YourPage_URL, var1_Name, value1, Param1_PopupTitle));
    Step 2 : Javascript function
    function openSPPopup(navigateURL, popUptitle) {
    var options = {
    width: popupWidth,
    height: popupHeight,
    url: navigateURL,
    scroll: 0
    SP.UI.ModalDialog.showModalDialog(options);
    return false;
    Step 3: The popup close code (in .cs file) – I do it this way as it is just close dialog code and easy to write.
    protected void btnClose_Click(object sender, EventArgs e)
    { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "PopupScript", "SP.UI.ModalDialog.commonModalDialogClose(1, 1);", true);
    Courtesy -
    Thread
    Try this - https://bramdejager.wordpress.com/2011/03/21/using-sp-ui-dialog-and-sp-ui-notify-from-code-behind/
    http://msdn.microsoft.com/en-us/library/ff798390.aspx
    http://stackoverflow.com/questions/9833907/asp-net-confirm-before-executing-codebehind
    http://www.codeproject.com/Questions/443131/Call-to-javascript-Function-from-code-behind-using
    http://www.c-sharpcorner.com/uploadfile/ledomoon/calling-code-behind-function-in-javascript/
    Hope they will help!
    Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply.

  • How to customize the SharePoint 2010 search query string parameters

    Hi All,
    I am trying to redirect default SharePoint search to a custom search results page.
    I modified the Search Settings to redirect to the URL that I want.
    But my custom search page takes different query string parameters to provide the results.
    Eg: SharePoint search passes k=search term when we perform a search. But my custom page needs
    test=search term
    I would like to pass 'test' instead of 'k' as a query string. Is this possible?
    Thanks
    Carol

    There is no way out of the box to change it.  You could always write your own control that passes the value or inherit from SearchBoxEx web part (if you are using a search center) to pass a different value.  Query String Filter web part won't
    help you here I am afraid.  However, wouldn't it be easier just to change your code to take the value that SharePoint passes you?
    Corey Roth - SharePoint Server MVP blog:
    www.dotnetmafia.com twitter: @coreyroth

  • Visual Web Part Value not Selecting in Page Redirection

     Hi..
     I have a Visual Web Part having DropDown Controls and adding Webpart in 3 Web Part Pages .. When we redirect from 1 page to another, the  selected dropdown values are not coming in 2nd and 3rd page..
    Ravindranath

    You have added visual web part in three different pages, drop down value will not be selected when you redirect to page 2 or page 3 because they are separate pages and a separate web parts added on each page. Each page has a separate page life cycle.
    You can only set dropdown value by passing query string parameter.
    Adnan Amin MCT, SharePoint Architect | If you find this post useful kindly please mark it as an answer.

  • Returning Name and Username from People Picker Field in Visual Web Part

    Dear All
    I am creating a visual web part that displays a list that I have created in SharePoint. One of the fields in the list is a People & Groups column type (People Picker) called 'Presented by'. In my web part, I would like to display the username and
    the name of the person who has been 'picked' in this field. However, my using <%# Eval("Presented by") %> only displays their name. How do I get this field to also return their username?
    Many thanks for your help
    Daniel

    You ca  use this code:- change it according to your need
    int requestForUserID = 0;
    string requestForUserLoginName = string.Empty;
    string requestForUserName = string.Empty;
    string userAccount = peoplePickerEmployee.CommaSeparatedAccounts;
    string[] UsersSeperated = peEmployeeOnBehalf.CommaSeparatedAccounts.Split(',');
    foreach (string user in UsersSeperated)
    SPContext.Current.Web.EnsureUser(user);
    SPUser spUser = SPContext.Current.Web.SiteUsers[user];
    requestForUserID = spUser.ID;
    requestForUserLoginName = spUser.LoginName;
    requestForUserName = spUser.Name;
    Mark ANSWER if this reply resolves your query, If helpful then VOTE HELPFUL
    INSQLSERVER.COM
    Mohammad Nizamuddin

  • How to pass query string from content editor webpart to another?

    Hi All,
    I am using content editor web-part to show GooglePiechart  for workflow status column in a list. When user click on chart, i need to show particular clicked area data in another list web-part. So that, i need to pass the query value from content editor
    web-part to another web-part. How to achieve this scenario?

    Hi Sam,
    What you can do is using SPD create a data view webpart which excepts query string value as filters as shown in the below article
    http://madanbhintade.wordpress.com/2012/01/08/sharepoint2010dataviewwebpart/
    http://sharepoint.stackexchange.com/questions/55184/how-to-filter-dataview-webpart-dvwp-from-query-string
    Then When you click on the pie charts particualr section perform a post back  by appending the required query string paramter to the same page on which your webpart exist
    Raghavendra Shanbhag | Blog: www.SharePointColumn.com
    Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
    Disclaimer: This posting is provided "AS IS" with no warranties.

  • Access denied error while adding visual web part

    i am trying to create visual web part using client side code in SharePoint 2013.
    i am able to deploy my web part but when I try to add it on a page it says " Access denied. You do not have permission to perform this action or access this resource" and when i try to debug it it shows exception: "The remote server returned
    an error: (500) Internal Server Error."
    Following is the code:
     protected void Page_Load(object sender, EventArgs e)
                var ClientContext = new ClientContext("http://172.20.30.100:1111/");
                        //SP.ClientContext.get_current();
                Web web = ClientContext.Web;
                ClientContext.Load<Web>(web);
                ClientContext.ExecuteQuery();
                var BU = web.Title;
                ListCollection ListColl = web.Lists;
                List list = ListColl.GetByTitle("LNT_Testimonial");
                CamlQuery CmlQry = new CamlQuery();
                CmlQry.ViewXml = @"<View>
                                        <Query>
                                          <Where>
                                            <Eq>
                                              <FieldRef Name='BU' />
                                              <Value Type='Text'>" + BU + @"</Value>
                                            </Eq>
                                          </Where>
                                        </Query>
                                        <RowLimit>1</RowLimit>
                                      </View>";
                Microsoft.SharePoint.Client.ListItemCollection items = list.GetItems(CmlQry);
                ClientContext.Load<ListCollection>(ListColl);
                ClientContext.Load<List>(list);
                ClientContext.Load<Microsoft.SharePoint.Client.ListItemCollection>(items);
                ClientContext.ExecuteQuery();
                //var testimonial = items.FieldValues["testimonial"];
                foreach (Microsoft.SharePoint.Client.ListItem item in items)
                    var testimonial = item.FieldValues["testimonial"];
    regards, Ritesh Anand

    I'm not sure if you are trying to create visual webpart or doing something else? As I understand from your code, maybe, you are trying to access list item. If you have access to the server (on-premise), you can check the ULS log for details of the error.
    Is it access denied or 'internal server errror'. If it's internal server error then more details can be found in SharePoint ULS log. About reporting service, not sure if it's related to your original question. Please try to use a single post to focus on single
    problem.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • UiXML and query string parameters

    Is there a simple way to access a query string parameter within the destination page?
    Example:
    - in my source page I have something like:
    <link text="My page destination"
    destination="page?param1=value1" />
    What I want is to be able to acces directly to the param1 within page.uix without handling events or writing any kind of java code.
    I have tried to use ctrl:page, ctrl:eventResult or ctrl:servletRequest without success (thought it was not the right thing to do but gave it a try anyway).
    As i understand (?) the doc query string parameters are event parameters:
    - does it mean we can only deal with query string parameters in an event handler?
    Oscar

    Hi Oscar -
    As i understand (?) the doc query string parameters are event parameters:
    - does it mean we can only deal with query string parameters in an event handler? Right. The UIX Controller allows you to pass data to a new page using URL parameters in one of two ways: as event parameters - in which case you need to have a corresponding event handler - or as page properties. So, the built-in data providers that are supported by the UIX Controller (ctrl:page, ctrl:eventResult) are designed for supporting these two mechanisms.
    If you do not want to write an event handler, then you could consider using page properties to pass your parameters. The following link shows how to use the pageURL bound value to construct a destination which includes a single page property:
    <link text="Go to target page" xmlns="http://xmlns.oracle.com/uix/ui">
    <boundAttribute name="destination">
    <pageURL name="targetPage" xmlns="http://xmlns.oracle.com/uix/controller">
    <properties>
    <property key="prop1" value="value1"/>
    </properties>
    </pageURL>
    </boundAttribute>
    </link>
    And the following sample shows how to bind to the same property:
    <styledText data:text="prop1@ctrl:page"/>
    Andy

  • Sharepoint visual web part

    Hello, I would like to create visual web part, that can be used within SharePoint LIST's edit item form...I want to include treeview into the webpart and load a directory structure to it...a direcotry structure is meant a Folder hierarchy from fileprint
    server - share.
    to browse through share I use:
    stringsourcePath
    ="D:\\";
    foreach(stringdr
    inSystem.IO.Directory.GetDirectories(sourcePath))
    but I am receiving this error:
    An exception of type 'System.Security.SecurityException' occurred in prva.dll but was not handled in user code
    Additional information: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
    stack trace:
       at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.CodeAccessPermission.Demand()
       at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
       at System.IO.Directory.GetDirectories(String path, String searchPattern, SearchOption searchOption)
       at System.IO.Directory.GetDirectories(String path)
       at prva.VisualWebPart1.VisualWebPart1.Page_Load(Object sender, EventArgs e)
       at System.Web.UI.Control.OnLoad(EventArgs e)
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Control.LoadRecursive()
       at System.Web.UI.Control.LoadRecursive()
    please, help if possible

    You code failes because of security permission,set <trust level="Full" />
    see these threads, should help you to resolve
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/3c10b18b-b098-4967-8664-137bee9c2dcc/request-for-the-permission-of-type-fileiopermission-failed?forum=sharepointdevelopmentlegacy
    http://forums.asp.net/t/1422162.aspx?System+Security+SecurityException+Request+for+the+permission+of+type+System+Security+Permissions+FileIOPermission+mscorlib+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failed+
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Create a Site Definition file with Visual Web part in Visual Studio

    I tried to create a site definition file in Visual Studio 2013 and SharePoint 2013 by following the MSDN tutorial:
    Walkthrough: Create a Basic Site Definition Project. Near the end, I added a virtual web part control to the site definition and registered MyWebPartControls in the site definition's default ASPX page as written in the MSDN tutorial:
    Unfortunately, IntelliSense doesn't show any MyWebPartControls: tags, and VisualWebPart1 is highlighted with a warning “Element 'SMWebPart3' is not a known element. This can
    occur if there is a compilation error in the Web site, or the web.config file is missing.”
    Since it’s a warning, I went ahead to build and deploy the solution. However, when I used the site definition template to create a subsite, it returned a parser error:
    Unknown server tag 'MyWebPartControls:TestSiteDef1.VisualWebPart1'
    I spent half day researching and debugging, and finally solved the problem. The issue is on the registration line:
    <%@ Register Tagprefix="MyWebPartControls" Namespace="TestSiteDef.VisualWebPart1" Assembly="$SharePoint.Project.AssemblyFullName$" %>
    The $SharePoint.Project.AssemblyFullName$ is a replaceable parameter to provide values for SharePoint solution items whose actual values are not known at design time. Unfortunately, it does not find the right assembly name during the deployment. It should
    be replaced by the Assembly’s Strong Name. Here is how I fixed the problem step by step:
    In Solution Explorer, open the package node and double click Package.package
    Click Manifest tab in the Package.package.
    Copy the full assembly name in the package’s manifest. It may be similar like this:
              Assembly="TestSiteDef,
    Version=1.0.0.0, Culture=neutral, PublicKeyToken=a300f1f2da8ae976"
    Back to the site definition’s default.aspx page, replace the
                     Assembly="$SharePoint.Project.AssemblyFullName"
    in the registration line with the copied text:
    Assembly="TestSiteDef,
    Version=1.0.0.0, Culture=neutral, PublicKeyToken=a300f1f2da8ae976"
    Change the Namespace from
    Namespace="TestSiteDef.VisualWebPart1"
    to
    Namespace="TestSiteDef".
    The line to register the web part in a site definition file will look like this:
    <%@
    Register
    Tagprefix="MyWebPartControls"
    Namespace="TestSiteDef "
    Assembly="TestSiteDef, Version=1.0.0.0,
    Culture=neutral, PublicKeyToken=a300f1f2da8ae976"
    %>
    Clean, build and deploy the solution. It works like charm. (Note: the warning message on visual web part may still exist, but you can ignore it).

    Assuming your .ascx.vb file is inheriting from the web part class, you can add the custom properties in the same manor (language syntax aside).
    Be sure to use the attributes to correctly identify and scope the properties. (see:
    http://www.sbrickey.com/Tech/Blog/Post/SharePoint_Attributes_for_Web_Part_properties)
    Scott Brickey
    MCTS, MCPD, MCITP
    www.sbrickey.com

  • How to Add a User Control to a SharePoint 2013 Visual Web Part ?

    Hi,
    1.I have created SharePoint 2013 Farm Solution through VS 2012.
    2.Added visual Web part
    3.Created a User control (Farm Solution ) and added some Control From tool Box.
    4.Drag and drop user control from solution explorer to visual web part.
    so its  Register tag and with prefix tag user controls automatically added on visual web part source. when i try to build solution it throws Exception:
    Exception :The name 'InitializeControl' does not exist in the current context.
    Please Provide solution after try/or proper workaround.
    Thanks,
    Siddheshwar

    Site name=http://sitename:22222/
    Visual Web part:
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Src="~/_controltemplates/15/SP2013Controls/SPControls.ascx" TagPrefix="uc1" TagName="SPControls" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SPWebpart.ascx.cs" Inherits="SP2013Controls.SPWebpart.SPWebpart" %>
    <uc1:SPControls runat="server" id="SPControls" />
    User Control Code:
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SPControls.ascx.cs" Inherits="SP2013Controls.ControlTemplates.SP2013Controls.SPControls" %>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="Button" />
    Deployement Location:{SharePointRoot}\Template\ControlTemplates\SP2013Controls\
    After User controls added on webpart .g.cs file getting blank.
    After 1st Build:
    'InitializeControl' does not exist in the current context
    The file '/_controltemplates/15/SP2013Controls/SPControls.ascx' does not exist.
    after 2nd Build Try:
    'InitializeControl' does not exist in the current context

  • Create a visual web part which get data from excel sheet and import it into sql server database in sharepoint 2010 (development)

    Hi,
    I want to create a visual webpart which will read data from excel sheet and import it in to sql server database.(using sharepoint development)
    I want to do it using visual webpart.
    Please help to solve the issue.
    Thanks in advance!
    Regards
    Rajni

    Hi  Rajni,
    Microsoft.Office.Interop.Excel assembly provides class to read excel file data, in your web part solution, reference the assembly, and following blog contains samples about how to read the excel file data,
    and import it to SQL  database.
    1.Create a Visual Web Part Project:Create
    Visual Web Parts in SharePoint 2010
    2.Read the excel workbook by using SPFile class:
    http://alancejacob.blogspot.in/2012/06/read-data-from-excel-file-and-insert-in.html
    http://stackoverflow.com/questions/14496608/read-excel-file-stored-in-sharepoint-document-library
    3.Export the excel workbook to SQL Server:
    http://www.c-sharpcorner.com/UploadFile/99bb20/import-excel-data-to-sql-server-in-Asp-Net/
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • Way to use Visual Web part in sharepoint 2010 without using/installing third party tools

    I want to know the way to use Visual Web part in sharepoint 2010 without using/installing third party tools.
    Please provide me a link where i can actually know how it is done.

    + to _eNo_,
    Visual Studio 2010 has support for visual webpart, you can find that under Visual C# node in the Installed Templates section (if your preferred language is C#)
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

Maybe you are looking for

  • IPhoto Crash on Import (9.2, after Lion/iCloud Update

    This first happens on when i plugged in the ipad and it pops up to ask if i want to upgrade iPhoto. Now, iPhoto still opens but whenever I try to import photo it would crash and quit itself. I have turned off photo stream, as if I have that on I cann

  • Applicatio​n builder error creating

    After install Labview 9.0f2, no longer is possible to build application Solved! Go to Solution.

  • Pages text boxes

    I just wanted to have a plain sheet of paper to type a letter with drag and drop icons. I chose Pages, word processing, blank sheet. I now have little boxes with plus signs, I can't move the text, I can't control the cursor. I am using Pages '08 on a

  • Post a mail on a particular date

    We have developed a site for a greeting shop.. Here we have few sanple cards to be send on an occassion. The problem here is, we need to send a mail on some other day(day selected by him - greater than today) automatically. like in greetings.yahoo.co

  • Adobe Forms & SRM 4.0

    We are trying to move from Smartforms to Adobe forms for PO output but we are running into issues when we try to set the PO output configuration as we can't find custom Adobe Form for selection. We are using SRM 4.0 so the first question would be "is