-1

I have a telerik window with multiple divs inside it whose visibility is set according to javascript function. Now I want to call a javascript function so that any visible div in that window is hidden onclose event of telerik window i.e. I have to pass the id of a div with visibility=visible in the window onclose event at runtime.

How do I do that?

function opendivinwindow(thediv) {
             var div = document.getElementById(thediv);
                div.style.visibility = "visible";
                var window = $("#Window").data("tWindow");
                window.center().open();  
            }

  function Onclose() {        
                var div = document.getElementById('resumetitle');
                div.style.visibility = "hidden";
            }

View

<% using (Html.BeginForm("Resumename", "resumewizard", FormMethod.Post, new { name = "Resumetitle",OnLoad="Error();"}))
          {%>
          <%=Html.Label("Step 1.Resume Name")%><br />
          <%=Html.Label("Please Enter Resume Name,Job Title and Objective")%><br />
         <%=Html.Label("Resume Name")%><br />
        <%=Html.TextBox("ResTitle")%><a href="javascript:opendivinwindow('resumetitle');">
        <img src=  "../../Content/img/module/QuestionMark.gif" /></a><br />
       <%-- <div id="resumetitle" style="visibility:hidden">Resume title</div>--%>
        <%=Html.Label("Desired Job Title/Position")%><br />
        <%=Html.TextBox("DesPos")%><a href="javascript:opendivinwindow('desiredposition');">
        <img src=  "../../Content/img/module/QuestionMark.gif" /></a><br />

        <%=Html.Label("Objective")%><br />
        <%=Html.TextArea("ResObjective")%>
        <a href="javascript:opendivinwindow('desiredobjective');">
        <img src=  "../../Content/img/module/QuestionMark.gif" /></a>
        <br />
        <%  string str = ViewData["Errormsg"].ToString();
        %>
       <div id="msgblock">
       <%=Html.Label(str)%>
       <%=Html.Hidden("error", ViewData["Errormsg"])%>
       <%=Html.Hidden("resumeid",ViewData["resumeid"])%>
       </div>
        <input id="SaveForwardButton1"  type="image" src="../../Content/img/buttons/SaveForwardButton.gif" onclick="return validation();" />


         <% Html.Telerik().Window()
         .Name("Window")
.Title("Telerik Window for ASP.NET MVC")
.Resizable(resizing => resizing
.MinHeight(250)
.MinWidth(250)
.MaxHeight(500)
.MaxWidth(500)
)
.Buttons(b => b.Maximize().Close())
.Content(() =>
{%>

<div id="resumetitle" style="visibility:hidden">Resume Name: (will NOT display to employers - max. 50 characters)

- The Resume Name will NOT display to employers. It is for your personal use, to help you identify each unique resume. You can store up to 5 resumes.</div>
 <div id="desiredposition" style="visibility:hidden">The Desired Job Title will appear at the top of your resume directly under the contact information heading and will be the first item potential employers see.

Use this field to state your desired Job Title or describe the type of position you are seeking.</div>
 <div id="desiredobjective" style="visibility:hidden">Enter the objective of your career move. This is a good opportunity to tell would-be employers what you are all about. Entering specific information regarding your specific history increases the visibility potential of your resume.</div>
<%})
.Width(300)
.Height(300)
.Visible(false)
.ClientEvents(events => events.OnClose("Onclose"))
.Render();
%>
<% }%>
mplungjan
  • 134,906
  • 25
  • 152
  • 209
iProgrammer
  • 3,057
  • 3
  • 30
  • 58
  • i have to pass the div id onclose event of window whose visibilty is true in that window how can i do this – iProgrammer Jul 12 '11 at 12:47
  • Seems you use jQuery too? I see a $("#Window"). If so, why not use it consistently? Like [How do you test if something is hidden in jQuery?](http://stackoverflow.com/questions/178325/how-do-you-test-if-something-is-hidden-in-jquery) – mplungjan Jul 12 '11 at 13:05

1 Answers1

0

Like this? Give the divs a class

function opendivinwindow(thediv) {
  $("#"+thediv).css("visibility","visible");
  var window = $("#Window").data("tWindow");
  window.center().open();  
}
function Onclose() {
  $(".myDivs").each(function() {
    if ($(this).css("visibility") == "visible") {
      $(this).css("visibility","hidden");
    }
  }
}
mplungjan
  • 134,906
  • 25
  • 152
  • 209