Solved

How to start serverside code using client side javascript

Posted on 2009-05-15
5
554 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 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