Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have two webpart right now on selectedindex changed of my textbox(TextboxFirstname) i send textbox data to consumer webpart, the problem is now that i have more then one textbox that i want to send on selectedindexchanged, my TextBoxLastname, i also want to do the same but then TextboxFirstName get also the data that i wrote in textboxlastname, should i use array or something?

This is my Provider here inside i have my textboxes that i want to send to my labels in my consumer,

Provider

C#
namespace Cv.Knowit.RegisterYourCv

{ [ToolboxItemAttribute(false)] public class RegisterYourCv : WebPart, IData { // Visual Studio might automatically update this path when you change the Visual Web Part project item. private const string _ascxPath = @"~/_CONTROLTEMPLATES/Cv.Knowit/RegisterYourCv/RegisterYourCvUserControl.ascx";

private Control control;

protected override void CreateChildControls()
{
    control = Page.LoadControl(_ascxPath);
    Controls.Add(control);

}
[ConnectionProvider("Employee")]
public IData GetMyData()
{
    return this;
}

public string Mydata
{
    get { return ((RegisterYourCvUserControl) control).MyData; }
}

} }


Consumer
C#
namespace Cv.Knowit.ReallityCv

{ [ToolboxItemAttribute(false)] public class ReallityCv : WebPart { // Visual Studio might automatically update this path when you change the Visual Web Part project item. private const string _ascxPath = @"~/_CONTROLTEMPLATES/Cv.Knowit/ReallityCv/ReallityCvUserControl.ascx";

Control control; private IData provider; protected override void CreateChildControls() { control = Page.LoadControl(_ascxPath); Controls.Add(control); }

protected override void OnPreRender(EventArgs e)
{
    if (provider != null)
    {
        if (!string.IsNullOrEmpty(provider.Mydata))
        {
            ((ReallityCvUserControl)control).MyData(provider.Mydata);
        }
    }
    //base.OnPreRender(e);
}

[ConnectionConsumer("Employee")]
public void ReceiveProvider(IData d)
{
    provider = d;
}

} }




My Interface
C#
namespace Cv.Knowit

{ public interface IData { string Mydata { get; } } }

My Provider has also
C#
public string MyData { get; set; }

My consumer has also
C#
public void MyData(string cvData)
{
    LabelFirstName.Text = cvData;
    LabelLastName.Text = cvData;

}

My textbofirstname looks like this
C#
protected void TextBoxFirstName_TextChanged(object sender, EventArgs e)
{

        if (TextBoxFirstName.Text != string.Empty)
        {
            MyData = TextBoxFirstName.Text;
        }

}

And my Textboxlastname looks like this
C#
if (TextBoxFirstName.Text != string.Empty)
        {
            MyData = TextBoxLastName.Text;
        }


Right now if i write something only in TextBoxFirstName, the same data get displayed in LabelFirstname And LabelLastName but i want TextboxFirstname in LabelFirstName and TextBoxLastname in LabelLastname, any suggestions?
Posted
Updated 11-May-13 22:25pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900