HEXAQ : A friendly question - answer site for IT professionals

How to pass value from usercontrol to page using modal popup extender in asp.net ajax


0

How to pass value from user control to page using modal popup extender in ajax I am getting value in page but my page does not refresh

My html on .aspx page is

  <asp:TextBox ID="txtMyId" runat="server"></asp:TextBox>
 <div>
            <ajaxToolkit:ModalPopupExtender ID="mpeSearchDoctor" runat="server" Enabled="true" TargetControlID="btnpoupTarget" PopupControlID="Panel2" BackgroundCssClass="modalBackground"></ajaxToolkit:ModalPopupExtender>
            <asp:Panel ID="Panel2" runat="server" CssClass="modalPopup1">
                <div>
                    <asp:LinkButton ID="lnkbCloseSearch" runat="server" Text="Close" OnClick="lnkbCloseSearch_Click"></asp:LinkButton>
                </div>
                <asp:Button runat="server" ID="btnpoupTarget" Style="display: none" usesubmitbehaviour="false" />
                <uc1:UCData runat="server" ID="UCData" />
            </asp:Panel>
        </div>

In code behind page C# code is below

 protected void Page_Load(object sender, EventArgs e)
    {
       // UCData.getmyid += UCData_getmyid;
        UCData.reporter += UCData_reporter;

    }

    void UCData_reporter(string text)
    {
        txtMyId.Text = text;
        mpeSearchDoctor.Hide();

    }

   protected void lnkbCloseSearch_Click(object sender, EventArgs e)
    {
        mpeSearchDoctor.Hide();
    }

    protected void show_Click(object sender, EventArgs e)
    {
        mpeSearchDoctor.Show();
    }

user control .ascx html code:

<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
    <asp:Button ID="btnsearch" runat="server" Text="search" OnClick="btnsearch_Click" />
    <asp:GridView ID="grdData" runat="server" AutoGenerateColumns="False" OnRowCommand="grdData_RowCommand">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate><%# Eval("Name") %></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate><%# Eval("First") %></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate><%# Eval("Last") %></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate><%# Eval("Age") %></ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:LinkButton ID="lnkbSearch" Text="Search" runat="server" CommandName="Search" CommandArgument='<%# Eval("id") %>'></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</ContentTemplate>

Code behind C# code of user control is below

 public event setPageText reporter;

 protected void BindData()
    {
        SampleBusinessController objSampleBusinessContoller = new SampleBusinessController();
        DataSet ds = new DataSet();
        ds = objSampleBusinessContoller.GetData();
        grdData.DataSource = ds;
        grdData.DataBind();

    }

    protected void grdData_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Search")
        {
            BindData();
            if (reporter != null)
            {
                //getmyid(e.CommandArgument.ToString());
                reporter(e.CommandArgument.ToString());                    
            }
        }
    }

    protected void btnsearch_Click(object sender, EventArgs e)
    {
        BindData();
    }

My text box value does not update through BindData function, but when I use view state and look at data I am getting data in view state.

How can I set or update value in Textbox on my .aspx page from user control?

Â
asked
 


≡ Total 1 Answer

0

Hi nehali,

Take a look the below link,

http://sandblogaspnet.blogspot.in/2009/07/working-with-modal-popup-extender.html

Hope it might be useful to you.

Â
replied


Enter your reply here
Answer Preview:
Viewed: 3815 times
Asked on: 7/13/2013
Permalink
Topics in this question
  50
  4
c#
  24
  1
Search Question
Similler Questions