Solved

How to start serverside code using client side javascript

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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