Solved

help convert vb.net event into javascript for better user experience

Posted on 2007-12-05
5
562 Views
Last Modified: 2012-05-05
i am using this function below and the user experience sucks because it does a postback.   how can i just create javascript so we dont have to do a postback eachtime the user selects a choice in any radiobutton.  

    Protected Sub RBL_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim RBL As RadioButtonList
        RBL = CType(sender, RadioButtonList)
        If RBL.SelectedItem.Text = "1" Or RBL.SelectedItem.Text = "2" Then
            Me.Panel3.Visible = True
                 
        End If
    End Sub

<asp:RadioButtonList
                                                                                                ID="jmirating" runat="server" AutoPostBack="True"
                                                                                                CssClass="whiteradio" onselectedindexchanged="RBL_SelectedIndexChanged"
                                                                                                RepeatDirection="Horizontal" TextAlign="Left" Width="403px">
                                                                                                        <asp:ListItem Value="5">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="4">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="3">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="2">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="1">-</asp:ListItem>
                                                                                                        <asp:ListItem Value="N/A">-</asp:ListItem>
                                                                                                    </asp:RadioButtonList>
                                                           
0
Comment
Question by:gianitoo
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:divinewind80
ID: 20411361
I assume you are not using AJAX, correct?  I would recommend that you do this.  Check out the link below for details:  

http://www.asp.net/ajax/

One reason why I say this is because you will most likely find it much easier to use an UpdatePanel in AJAX than to try to unhide a hidden panel in Javascript.  Often, I have found, Javascript has issues finding ASP.NET controls that are hidden...
0
 
LVL 1

Author Comment

by:gianitoo
ID: 20411384
i have tried the update panel but there is an issue with my multiview control.  
when i go next  it does not go to the top of the page in the next view.   it is an issue with updatepanel that i can figure out.  i have asked but nobody helps me.  

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23000618.html
0
 
LVL 9

Expert Comment

by:divinewind80
ID: 20411534
I see.

Try sticking the panel in a div, like so:

<div style="visiblity:hidden;" id="div1" runat="server">
<asp:panel runat=server id="panel1" visible="true" />
</div>

The ID and RUNAT are probably necessary... but it may take a little tinkering.  Give it a try and see what happens.  You should be able to reference this div from Javascript.  If you need some ideas on how to trigger the Javascript from a serverside control, let me know.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 20411553
yes i haveno idea how to do it from javascript.  can u provide full code?
0
 
LVL 9

Accepted Solution

by:
divinewind80 earned 500 total points
ID: 20412089
I would suggest something like the following:

-- In HTML --
<script language="javascript">
setInterval("checkchanged()",2500); //this will check every 2.5 seconds

function checkchanged()
{
if(document.getElementById('RBL).selectedIndex==1||document.getElementById('RBL').selectedIndex==2)
{
document.all.div1.style.visibility='block'
}
}
</scipt>

You will have to mess around with this a bit... but the idea is there, at least.
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to get the web content with different encodings 2 46
ASP.net Run 3 sliders vertically as opposed to horizontally 9 21
Delete HTML table rows 12 29
imap mails 1 23
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 an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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