Click here to Skip to main content
15,886,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts,

I want to create a jquery function which is like a dialog window and that dialog window should show my user control. I created user control. But I don't know jquery, so can anyone help me with this please.

Here is my User control
XML
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Brands.ascx.vb" Inherits="Controls_Brands" %>
<asp:PlaceHolder ID="ucbrands" runat="server" />

<table id="tblBrands" border="3" cellspacing="3" cellpadding="0" style="padding:0px;margin:0px;border:0px">
<tr>

 <td colspan="2" align="center"><label>
 <input type="checkbox" name="chk1" id="chk1" />
  GoodYear</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch2" id="ch2" />
  Dunlop</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch3" id="ch3" />
  Kelly</label></td>

</tr>
<tr>
<td colspan="2" align="center"><label>
 <input type="checkbox" name="ch4" id="ch4" />
  Pirelli</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch5" id="ch5" />
  Kumho</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch6" id="ch6" />
  Aeolus</label></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
 <input type="checkbox" name="ch7" id="ch7" />
  Centara</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch8" id="ch8" />
  Venezia</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch9" id="ch9" />
  Maxtrek</label></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
 <input type="checkbox" name="ch10" id="ch10" />
  Michelin</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="ch11" id="ch11" />
  Uniroyal</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="chk12" id="chk12" />
  Continental</label></td>
</tr>
<tr>
<td colspan="2" align="center"><label>
 <input type="checkbox" name="chk13" id="chk13" />
  Yokohama</label></td>
  <td colspan="2" align="center"><label>
 <input type="checkbox" name="chk14" id="chk14" />
  Others</label></td>
</tr>
</table>



Using Jquery how to show a dialog window with items as listed in the above user control? Your help is much appreciated.
Posted

You (instead of creating a window or a dialog) should use a simple div element, and inside you can load the content of your User control. I have always said, that ASP.NET code once streamed down to the client is in the form of HTML always. So, there is no need to worry of how you content would look like, it will be simple HTML markup with a few classes ids and other attributes.

You can create a simple div element, such as

HTML
<div id="user-control"></div>


Done. Now, you can load the data from the server's web page where your control is located at, and you can use jQuery's ajax or get loaders to get the data. I would prefer using the get loader, or load to fill the element with the content from the server.

JavaScript
$('#user-control').load('<url-of-the-control>');


This would load the content of your User control's HTML markup into the div element. You can after that use the CSS styles to show the div as a floating window; more like a dialog box. It now then would be a simple HTML document's element. That can be easily edited using CSS, or jQuery itself.

More on jQuery's load function[^].
 
Share this answer
 
v2
Comments
sudevsu 26-Feb-15 8:44am    
Well, My main content page is very tightly packed. So I want to create a usercontrol and show that as popup or dialog window. Do you think your solution works for my requirement. because I am not sure of Jquery. I have like 0 knowledge on it.
Afzaal Ahmad Zeeshan 26-Feb-15 8:48am    
Yes, because I myself have tried using the same thing in my applications, to load some external data from server (using Ajax or a load function) and then displaying it in a div; using CSS and styling the div as a popup. Just the way, Facebook and/or many other web sites do.
sudevsu 26-Feb-15 8:59am    
Ok Thank you Ahmad.
Now div element should be created in normal webpage page1.ASPX correct?. On this page1.ASPX I want to show my Popup.
Sorry for repeating same thing. Because I don't know how to start this. This work is my career decider. So plz bear with me.
I will call you back incase I need some help.
Afzaal Ahmad Zeeshan 26-Feb-15 9:05am    
Yes, you can simply just create an empty container (that is an empty div), and using the jQuery you can populate that empty container whenever you want to. Using the above code. You can then show the popup, make sure the div have enough CSS styles to display the container as a popup. You can set some backgrounds, z-index etc.
sudevsu 26-Feb-15 9:11am    
Alright so my checkboxes, drop downs will be in my user control page.
Div tag will be in ASPX web page where I want the pop to be show.
Add to solution 1, you may explore the dialog element introduced in HTML5 to show a model dialog, see demo at jsfiddle[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900