Printing the contents of a div in IE - c#

Ok so for some reason my div prints out the way it should in Firefox and Chrome but then when I go to IE it doesnt work. It only prints out one page of the div then the header and footer. I have tried adding some new code to see if I can get it to work better but still having issues. The current code does print out fine but doesnt inherit the divs styling that they had on the page and not in an external style sheet. The commented out code below is what they had there before. Does anyone have any help?
function buildPrint() {
var sourceDiv = document.getElementById("display_div");
var WindowObject = window.open('', 'print_div', 'width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes');
WindowObject.document.writeln(sourceDiv.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
//document.getElementById("print_div").innerHTML = sourceDiv.innerHTML;
//window.print();
}
<asp:Content ID="Content3" ContentPlaceHolderID="BodyPlaceHolder" runat="server">
<div id="display_div">
<asp:CheckBox ID="showAllOptionals" runat="server" Text="Show All Optionals" AutoPostBack="true" />
<asp:Literal ID="mainTable" runat="server" />
</div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="PrintContent" runat="server">
<div id="print_div" style="page-break-after:avoid;">
</div>
</input><input onclick=\"buildPrint();\" id=\"printBtn\" type=\"button\" value=\"Print\">

I got the solution, I had to add different CSS to it so the div overflowed and printed. Thanks for all the help

Related

How To Make Slideshow Using ASP.NET Repeater

I'm dynamically loading my image urls from database.
Here is my current code for the repeater to load the images
<asp:Repeater ID="Repeater1" runat="server" Visible="True">
<ItemTemplate>
<a><asp:Image ID="Image1" runat="server" Width="1200" Height="300" ImageURL='<%#Eval("ThumbnailPath")%>' class="slide" /></a>
</ItemTemplate>
</asp:Repeater>
That is my .ASPX page where the image comes out but it only shows my images vertically stacked how do I make it into slideshow?
Here is my code To load the pictures to the repeater
GallerySTR = ConfigurationManager.ConnectionStrings["PPDB"].ConnectionString;
GalleryCN = new SqlConnection(GallerySTR);
string LoginQuery = "SELECT * FROM Albums";
GalleryCN.Open();
GalleryCMD = new SqlCommand(LoginQuery, GalleryCN);
GalleryDA = new SqlDataAdapter(GalleryCMD);
GalleryDS = new DataSet();
GalleryDA.Fill(GalleryDS);
Repeater1.DataSource = GalleryDS;
Repeater1.DataBind();
I can perfectly load the pictures but I can't seem to make it into slideshow. some javascript perhaps? or some technique or codes?
Go get this
jQuery Slideshow
This will go in your aspx designer
<div class="slideshow" data-transition="crossfade" data-loop="true" data-skip="false">
<ul class="carousel">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<li class="slide">
<img src='<%# DataBinder.Eval (Container.DataItem, "ImageUrl") %>' alt="" width="440" height="200" />
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</div>
Bind your code to this repeater, and don't forget to include the script includes in the aspx page.
UPDATE
Add your required css files link in the head section of the html page. You will need to adapt to your project.
<link href="Content/Slideshow.css" rel="stylesheet">
And at the end of the body tag, you will add the js scripts
<script type="text/javascript" src="Scripts/Slideshow.js"></script>

Panel.GroupingText in ContenPlaceholder shows first in all Panels

On my asp webforms page I have code similar to this:
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContentPlaceHolder">
<asp:Panel ID="pnltest1" runat="server" GroupingText="Panel1">
Panel 1
</asp:Panel>
<asp:Panel ID="pnltest2" runat="server" GroupingText="Panel2">
Panel 2
</asp:Panel>
</asp:Content>
The problem is that in both fieldsets the legend-tag has the text of the first panel groupingtext ("Panel 1").
If I test it without the use of a master page all is correct.
Can someone explain this?
Thanks to Tim I have found the error. I was focusing on web-controls while the error was in bad coded javascript.
The following line of javascript produced the error:
$('legend').html('<span>' + $('legend').html() + '</span>');
After changing it to
$('legend').each(function () {
$(this).html('<span>' + $(this).html() + '</span>');
});
all is working fine again.

Not able to hide the div

I'm not able to hide the in code. I have given Id to div also I have given runat server property to it but on running the code Div is visible . Please help.
My code is like this :
<a href="RoomTypeView.aspx">
<div class="dash-thum-bg" id="rt" runat="server">
<img src="../App_Themes/Akeel/images/thumb-1.gif" />
<span>Room Type</span>
</div>
In code I am writing
rt.visible=false
Try to wrap your div around a panel. Then u can hide the panel in the code behind.
<asp:Panel runat="server" id="divtohide">
<a href="RoomTypeView.aspx">
<div class="dash-thum-bg" id="rt" runat="server">
<img src="../App_Themes/Akeel/images/thumb-1.gif" />
<span>Room Type</span>
</div>
</asp:Panel>
code behind
divtohide.visible = false;
You can use javascript -
function hideMyDiv()
{
document.getElementById('rt').style.visibility="hidden";
}
Add a style -
.hidden {
display:none;
}
Now call it by codebehind

ASP.NET Form Fields Not POSTing from colorbox

I've got a form that is displayed inside a jQuery colorbox. When the form is submitted, the fields within that form are not being posted back to the page. I modified the javascript to store the form fields into hidden fields on a submit and those DO post back. The problem is, since this is a login box, I really don't want to move the password around like that. The main form content is inside an update panel. Here is the code for my master page:
<form id="myform" runat="server" clientidmode="Static" method="post">
<asp:ScriptManager ID="ecommerceManager" runat="server" ClientIDMode="Static" EnableViewState="False" EnablePageMethods="True">
<Scripts>
<asp:ScriptReference Path="~/js/jquery-1.6.1.min.js" />
<asp:ScriptReference Path="~/js/jquery.colorbox.min.js" />
<asp:ScriptReference Path="~/js/eCommerce.js" />
</Scripts>
</asp:ScriptManager>
<div style="width: 940px; margin-left: auto; margin-right: auto;">
<div align="left">
TOP OF THE PAGE
<asp:ContentPlaceHolder ID="bodyContent" runat="server" ClientIDMode="Static">
</asp:ContentPlaceHolder>
BOTTOM OF THE PAGE
</div>
</div>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(closeLoading);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(loadData);
</script>
</form>
Here is some of the code from my main default page that uses the master page:
<asp:Content ID="mainContent" ContentPlaceHolderID="bodyContent" runat="server">
<asp:UpdatePanel ID="ecommerceUpdate" runat="server" ClientIDMode="Static">
<ContentTemplate>
<asp:Panel ID="pnlEcomMain" runat="server" CssClass="ecom_main" ClientIDMode="Static">
<asp:HiddenField ID="statusField" runat="server" ClientIDMode="Static" ViewStateMode="Disabled" EnableViewState="False" />
<asp:HiddenField ID="hdnUsername" runat="server" ClientIDMode="Static" ViewStateMode="Disabled" EnableViewState="False" />
<div class="add_product">
<div class="add_product_menu text_12_bold">
<asp:Image ID="imgAddProducts" ImageUrl="~/images/ecom_icon_add_2.gif" CssClass="std_btn" AlternateText="Add Products" runat="server" ClientIDMode="Static" />Add Additional Products:<br /><br />
<asp:DropDownList ID="newproduct" runat="server" ClientIDMode="Static"
onchange="addProduct()">
</asp:DropDownList>
</div>
</div>
</asp:Panel>
<div class="clear"></div>
<!--- HERE IS THE COLORBOX POPUP CONTENT --->
<div style="display: none; visibility: hidden;">
<div id="inline_login">
<p><strong>User Login Details Go Here</strong></p>
User Name: <asp:TextBox ID="loginName" runat="server" ClientIDMode="Static" EnableViewState="False" ViewStateMode="Disabled" /><br />
Password: <asp:TextBox ID="loginPassword" runat="server" TextMode="Password" ClientIDMode="Static" /><br />
<input type="button" name="loginBtn" id="loginbtn" value="Login" onclick="javascript:validateLogin()" />
</div>
</div>
</asp:Panel>
<asp:Label ID="xmlContent" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
The new product field properly posts, but the username and password doesn't UNLESS I copy it to the hidden fields before a post. I'm guessing maybe it's a conflict with the update panel? I was originally trying to get a Login Control working in the Update Panel but read in the forums that there is a known problem with this.
Any insight on this would very tremendously be appreciated. I'm using firebug and can confirm that the fields simply aren't in the post which is why ASP isn't finding them.
Apparently, despite being inside the form, the colorbox actually moves the content outside the form. I was able to resolve this by adding this line of code to my JavaScript submit function:
jQuery('#inline_login').appendTo('form');
Hope it helps someone else!
I have never used jQuery colorbox, but i had a similar problem with jQuery UI modal popup. What it was doing was, when i attached the popup it moved the content div outside of the asp.net form so the controls were not getting posted back.
Another option that worked for me in a particular .NET CMS (DNN) was to take Jack's fix and attach to the cbox_complete event. Posting in case someone else might find this useful.
$(document).bind('cbox_complete', function () {
$("#colorbox, #cboxOverlay").appendTo('form:first');
});
Just had a similar problem with colorbox & form, solved it this way. My problem was that the submit wasn't working since the fieldsets were stripped of the form tag; So if your form isn't posting in colorbox, try this, sending in the form id as the href for the colorbox content
$(document).ready(function () {
$('#login-trigger').click(function () {
$.colorbox({
inline: true,
href: "#login-form",
close: "×",
onOpen: function () { $('#login-content').css({ display: 'block' }); },
onClosed: function () { $('#login-content').css({ display: 'none' }); }
});
return false;
});

add radiobuttonlist to ascx

i want to add a rsionbuttonlist to my ascx web control.. i keep getting an error that ineed to put the radionbuttonlist inside a tag. is there a way around this?
"
<%# Control Language="C#" AutoEventWireup="true" CodeFile="step2.ascx.cs" Inherits="ascx_step2" %>
<div id="step2" runat="server">
<asp:RadioButtonList id="answers" runat="server">
</asp:RadioButtonList>
<div>
"
in the code behind:
ListItem item = new ListItem("a", "a")
answers.Items.Add(item);
the error :
control "ctl_00..." of type radiobutton must be placed inside a form tag with runat=server
<table>
<tr>
<td>
Drag and drop from the tool box, in UI mode
<td>
</tr>
</table>
Make sure the control is added to the containing page (containing a form element) properly and the radio button list is declared correctly:
<asp:RadioButtonList ID="rblSomeRadioButtonList" runat="server">
<asp:ListItem Text="Something" Value="True"/>
</asp:RadioButtonList>
Here are a few things to check:
Perhaps this was just a typo, but your example .ascx markup has a leading and trailing quote that does not belong in a real .ascx file.
Ensure that your user control is placed on a page within the form tag.
MyPage.aspx:
<html>
<body>
<form id="form1" runat="server">
<myprefix:MyUserControl ID="mycontrol" runat="server" />
</form>
</body>
</html>
If you are dynamically adding your user control to the page in code-behind, make sure you are adding it to something that is already inside the correct form tag.

Categories