Solved

How to start serverside code using client side javascript

Posted on 2009-05-15
5
528 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Asp.net mvc entity issue 6 31
Runtime Exceptions when trying to submit data 28 36
Server Error 11 47
Gridview alignment 1 8
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

26 Experts available now in Live!

Get 1:1 Help Now