Pass value and reload User Control from Javascript

I have a custom control (because I am using the same thing on another page, so I thought I should reuse the code and not double my work), but on this page I am showing a list of companies and each one is numbered company , I need to pass this company number to this custom control and it should reload using this company number.

How can i do this?

what i have so far:

alt text http://www.balexandre.com/temp/2009-09-17_0917.png

link Show company structure made from

<a href="javascript:showStruct('112:201334607','5564967221');" 
   class="showStructLink">Show company structure</a>

      

showStruct method is written as

  function showStruct(pid, cnr) {
     if (_showStrut == 0)
        return;

     // fancy stuff to be more apealing visually
     $("#tdSearch").removeClass("tabTitleUp01").addClass("tabTitleDownUp01");
     $("#tdStruct").removeClass("tabTitleDownUp02").addClass("tabTitleUp02");

     $("#srtr1").hide();
     $("#srtr2").hide();
     $("#sttr1").show();

     // enable Search Results tab to be clicked in order to get back
     $("#tdSearch")
        .addClass("pointer")
        .bind("click", function() { hideStructure(); });

     // pass the company number and reload wcCompanyStruture web user control
     // __doPostBack('RefreshWebUserControl', cnr);
  }

      

I can create a simple aspx page with a control inside and from jQuery call $ .get () to start and populate the control correctly, but I really want to know how to do it correctly using the ASP.NET AJAX method to send the number and call RefreshData On him

it is easy with code-behind to update a custom control simply by calling

wcCompanyStruture.RefreshData("companyNumberHere");

      

what do I need to do in my User Control part and well in the showStruct method to create this behavior?

All help is appreciated, thanks.

+2


source to share


3 answers


I know this is not the answer to your question, but I think you may be asking the wrong question.

It looks to me like you have a search result + viewing a detailed script where you are going wrong.

When you click Show Company Structure, do you want to see the details on the second tab correctly? If this is the case then the tabulation approach would be confusing for the user, it would be better if the modal popup would show the details. With no postback, just AJAX loads the detail page into a modal popup.

It is very easy with JQuery using the dialog widget in JQueryUI and the AJAX load function $('#SomeDiv').load('details.aspx?id='+companyid);



http://docs.jquery.com/Ajax/load#urldatacallback

This will give a much better user experience and is surprisingly easy to code.

Hope this helps.

+5


source


You can use LinkButton

Show Company Structure for each link and set the property CommandArgument

with the corresponding company ID. LinkButton

will result in postback.

The second solution is to use a hidden variable: <input type="hidden" id="hiddenCompanyNumber">

and set its value in the method showStruct

. Then you can call __doPostBack()

for which you need a control that I can respond to.



Overall, I think the first solution is less hacky.

0


source


You can find it here

http://codeclimber.net.nz/archive/2007/06/26/how-to-refresh-an-updatepanel-from-javascript.aspx

don't worry about the title of the article, which has what you need. Just follow four steps and you are ready to go.

-2


source







All Articles