Solved

How to start serverside code using client side javascript

Posted on 2009-05-15
5
517 Views
Last Modified: 2012-05-07
Hi Experts,
I have a combobox and use javascript to adjust the behavior. One of the events I use is OnClientDropDownClosed. However next to starting javascript to adjust the behaviour I need the same event or a later event to start a sub server side. What is the best approach to this?

Best regards, MB
0
Comment
Question by:mark_norge
  • 3
  • 2
5 Comments
 

Author Comment

by:mark_norge
ID: 24396267
Below the current code

<telerik:RadComboBox ID="cboVessels"
                    Runat="server"
                    AutoPostBack="True"
                    OnClientDropDownClosed="onDropDownClosing"
                    HighlightTemplatedItems="True">
                    <ItemTemplate>
                        <div onclick="StopPropagation(event)">
                            <asp:CheckBox runat="server" ID="CheckBox"/>
                            <asp:Label ID="Label" runat="server"
                                AssociatedControlID="CheckBox"
                                Text ='<%# DataBinder.Eval(Container.DataItem, "VesselName") %>'>
                            </asp:Label>
                        </div>
                    </ItemTemplate>
                </telerik:RadComboBox>


<script type="text/javascript">
            var cancelDropDownClosing = false;
           
            function StopPropagation(e)
            {
                //cancel bubbling
                e.cancelBubble = true;
                if (e.stopPropagation)
                {
                    e.stopPropagation();
                }
            }

            function onDropDownClosing()
            {
                cancelDropDownClosing = false;
            }
        </script>
    </telerik:RadCodeBlock>
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 24398068

Hi,

[aspx page]
<img src="" onclick=<%# RunFunction(this) %>>

[code behind]
public string RunFunction()
{
    return "something";
}
0
 
LVL 18

Accepted Solution

by:
carlnorrbom earned 500 total points
ID: 24398100
Hi,

I meant to write in the above post that I know that this type of implementation usually works, which means you should be able to declare it likewise in the properties of the RadComboBox, i.e.:

[apsx page]
OnClientDropDownClosed=<%# onDropDownClosing %>

[code behind]
public void onDropDownClosing(object sender, eventargs e) {
    //logic to do something.
}

I think your code-behind function must be declared as public (protected might work??).

/Carl.
0
 

Author Comment

by:mark_norge
ID: 24398914
Thanks for your reply Carl,

If I read your answer correctly the suggestion is to start the server side sub on an event.

However the problem is that I am able to start a server side sub and also to start javascript on the event OnClientDropDownClosed. However I am not able to do both on the same event and this is what I need.
So possible solutions I see are:
1. Start the server side sub from client side javascript (however this does not seem to be easy / possible if I read other posts).
2. Start the server side sub and perform javascript or comparable code server side.

Regards, MB
0
 

Author Closing Comment

by:mark_norge
ID: 31581945
I was able to do what I wanted using __doPostBack. But thanks for helping me getting into the right direction.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now