Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SharePoint > SharePoint Development
|
SharePoint Development Programming and development for SharePoint Portal Server and Windows SharePoint Services
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SharePoint Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 6th, 2011, 12:13 PM
Authorized User
 
Join Date: Aug 2006
Posts: 39
Thanks: 1
Thanked 0 Times in 0 Posts
Smile How to connect two visual webparts in sharepoint 2010

Hi,

I have two visual webparts named provider and consumer. In provider there is a textbox and a button. I want to send textbox value to consumer which is a gridview and which should filled up accordingly.

On consumer there is a dropdown with autopostback = true. If I dont pass value from textbox in provider, this dropdown should work for filling up the gridview.

Now the problem:

When at the first time I pass some value from textbox, the consumer is refreshed. But when I select any item from dropdown, it is posted back, but again shows the first item of the dropdown and grid is not refreshed.

My code in consumer:

Code:
protectedoverridevoid OnPreRender(EventArgs e)
{
try
{
base.OnPreRender(e);
if (_provider != null)
{
   if (_provider.CaseNo != "")
   {
     HttpContext.Current.Session["CaseNo"] = _provider.CaseNo; //This is used by method which is filling the gridview in codebehind of visual webpart's ascx.cs file
     Label lbl = newLabel();
     lbl.Text = " : " + _provider.CaseNo;
     this.Controls.Add(lbl);
   }
 
   Control control = Page.LoadControl(_ascxPath);
   Controls.Add(control);
}
}
catch (Exception ex)
{ }
}

The label always shows the value of textbox, even if I did not click to button in provider (I think on every postback the value from provider is sent to consumer)

PLEASE HELP.

Thanks
Nitin

Last edited by nitinp; January 6th, 2011 at 12:18 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Are Webparts running only with IE ? mrf ASP.NET 2.0 Basics 1 July 24th, 2010 08:45 AM
WebParts not working at all... Jurjen BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 3 April 10th, 2008 03:51 PM
ADS authentication for using Webparts ayyub123 ASP.NET 2.0 Basics 0 May 29th, 2007 11:34 PM
webparts authentication ayyub123 ASP.NET 2.0 Basics 0 May 28th, 2007 12:53 AM
Verbs not showing on WebParts skafando BOOK: Professional Web Parts and Custom Controls ASP.NET ISBN: 0-7645-7860-X 1 December 11th, 2006 10:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.