today i have certain problem using user control (.ascx) in asp.net technology. currently, i have scenario where the ideas are to put modal jquery mobile modal into ascx. then save the data based on click. for this condition, i have this coding
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="IndexPanel1.ascx.cs" Inherits="WebPGN.Pages.control.indexPanel1" %>
<style>
.btn-size {
width: 50px !important;
}
</style>
<div>
<i class="icon-pencil"></i>
<div data-role="popup" id="myPopup" style="width: 1000px;" data-history="false">
<div class="modal-header">
<h4 style="font-family: '__Helvetica Neue LT Std_5'; font-weight: 500; font-size: 16px;"><i class="icon-edit"></i> Edit Information</h4>
Close
</div>
<div class="modal-body">
<div class="col-md-12">
<table class="table table-responsive" border="0" style="border-color: #FFFFFF;">
<tr class="form-group">
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Header Text</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Header_Eng" Visible="true" EnableViewState="true" ClientIDMode="Static" />
</td>
<td style="width: 3%; border-top: 0px solid #f4f4f4 !important;"></td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Judul Teks</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Header" ClientIDMode="Static" />
</td>
</tr>
<tr class="form-group">
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Body Text</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<textarea rows="6" cols="90" id="txt_Panel1_Body_Eng" runat="server" style="height: 250px;"></textarea>
</td>
<td style="width: 3%; border-top: 0px solid #f4f4f4 !important;"></td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Konten Teks</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<textarea rows="6" cols="90" id="txt_Panel1_Body" runat="server" style="height: 250px;"></textarea>
</td>
</tr>
<tr class="form-group">
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Tag</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Tag_Eng" ClientIDMode="Static"/>
</td>
<td style="width: 3%; border-top: 0px solid #f4f4f4 !important;"></td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Label</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Tag" ClientIDMode="Static"/>
</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer" style="border-top: 0px solid #e5e5e5;" id="modal-footer">
<a class="btn btn-primary" href="#myPopup" data-rel="back" style="color: #fff;">Cancel</a>
<a class="btn btn-primary" href="#myPopup" ID="btnSaveHomePanel1" data-rel="back" runat="server" style="color: #fff;">Save</a>
</div>
</div>
</div>
for some reason, i want to use this ascx for example to send data to the server side. however, i have problem because when using asp.net button, the event doesnot fire back. can anyone give me more advice to accomplish this current condition. or should i use bootstrap modal rather than jquery mobile ui ? and how to use ascx as modal ? thank you very much :)
PS: i am using
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
you have to try bootstrap Modal like
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script
src="https://code.jquery.com/jquery-2.2.4.js"
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
crossorigin="anonymous"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<asp:LinkButton ID="btn_SearchCriteria" runat="server" Text="Search Vehicles" data-toggle="modal" data-target="#myModal"><p class="btn btn-primary">Purchasing Tool</p></asp:LinkButton>
<div aria-labelledby="myModalLabel" class="modal fade" id="myModal" role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 style="font-size: 18px; font-weight: 600">Purchasing Tool and Analysis</h1>
<button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<asp:Panel ID="pnlSubItems" runat="server" CssClass="modalBox" Width="100%">
<asp:Repeater runat="server" ID="repVehicleInfo" OnItemDataBound="repVehicleInfo_ItemDataBound">
<ItemTemplate>
<ul class="media-list">
<li class="media">
<div class="media-left">
<img src="../../images/SystemImages/car-avatar.png" style="width: 250px; height: 200px" />
<br />
<asp:Label ID="lbl_stockno" runat="server" Style="font-weight: 600" Text='<%# Bind("StockNumber") %>'></asp:Label>
</div>
<div class="media-body">
<%--2001 Holden Astra TS 12/00-12/04--%>
<h1 class="media-heading" style="font-weight: 600">
<asp:Label ID="lbl_heading" runat="server" Text='<%# Bind("Description") %>'></asp:Label></h1>
<div class="col-sm-8">
<table class="table table-responsive">
<tr>
<td>Body Style:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_bodystyle" runat="server" Text='<%# Bind("BodyType") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Engine:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_engine" runat="server" Text='<%# Bind("Engine") %>'></asp:Label>
</td>
</tr>
<tr>
<%-- <td>License No:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_linceno" runat="server"></asp:Label>
</td>--%>
<td>Transmission:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_transmission" runat="server" Text='<%# Bind("Engine") %>'></asp:Label>
</td>
</tr>
<tr>
<%-- <td>Reg No:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_regno" runat="server"></asp:Label>
</td>--%>
<td>Odometer:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_odometer" runat="server" Text='<%# Bind("Odometer") %>'></asp:Label>
</td>
</tr>
<tr>
<%-- <td>Color:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_color" runat="server"></asp:Label>
</td>--%>
<td>Purchased From:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_PurchasedFrom" runat="server" Text='<%# Bind("PurchasedFrom") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Purchase Amount:</td>
<td style="font-weight: 600">$<asp:Label ID="lbl_PurchaseAmount" runat="server" Text='<%# Bind("PurchaseAmount") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Sale Amount:</td>
<td style="font-weight: 600">$<asp:Label ID="lbl_SaleAmount" runat="server" Text='<%# Bind("SalesAmount") %>'></asp:Label>
<button id="lbtn_makemodel" href="#makemodel" type="button" class="btn btn-sm btn-primary pull-right" data-toggle="modal">
<i class="fa fa-cogs" aria-hidden="true"></i>Make/Model</button>
</td>
</tr>
<tr>
<td>Estimated Profit:</td>
<td style="font-weight: 600">
$<asp:Label ID="lbl_Estimatedprofit" runat="server" Text='<%# Bind("EstimatedProfit") %>'></asp:Label>
<button id="lbtn_anaylse" href="#anaylse" type="button" class="btn btn-sm btn-primary pull-right" data-toggle="modal"><i class="fa fa-pie-chart" aria-hidden="true"></i>Anaylse</button>
</td>
</tr>
<tr>
<td>App Price:</td>
<td style="font-weight: 600">
$<asp:Label ID="lbl_AppPrice" runat="server" Text='<%# Bind("PurchaseAmount") %>'></asp:Label>
</td>
</tr>
</table>
</div>
<div class="col-sm-4">
<asp:Repeater runat="server" ID="repPartsDetail">
<HeaderTemplate>
<ul class="list-group">
</HeaderTemplate>
<ItemTemplate>
<li class="list-group-item">
<asp:Label ID="lbl_Partname" runat="server" Text="Engine" />
<span class="badge">
$<asp:Label ID="lbl_partprice" runat="server" Text="0" Style="float: right;" />
</span>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
</asp:Panel>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
First of all add Bootstrap CSS and Bootstrap JS.
then Use this code
This code work for me. like when i click on linked button Bootstrap Modal Show
you can use this Webcontrol Any where and bind data on CodeBhind in ascx.cs file
Related
I tried looking for similar questions but couldn't find any. My aspx file looks something like this
<div align="center" style="height: 350px; overflow-y: scroll; overflow-x: scroll; width: 100%;">
<asp:Table ID="tblReport" Font-Size="11px" runat="server" ViewStateMode="Enabled">
<asp:TableHeaderRow Height="30px" ForeColor="#FFFFFF" BackColor="#3b3b3b" Style="font-weight: bold; text-align: left !important; padding-left: 3px; color: #FFF; border-right: 1px solid #ddeaf7;" HorizontalAlign="Center">
</asp:TableHeaderRow>
</asp:Table>
</div>
Now whenever there are too many columns, the width gets fixed to 100% even though I don't have a max-width property. And the text in the cell ends up in multiple lines. I want it to horizontally overflow out of the div instead.
Edit: Looks like adding this ended up fixing it.
td {
white-space: nowrap;
}
Simple html snippet to demonstrate -
div {
width: 10%;
overflow: auto;
}
<div>
<table>
<tr>
<th>A</th>
<th>B</th>
<th>C</th>
<th>D</th>
<th>E</th>
<th>F</th>
<th>G</th>
<th>H</th>
<th>I</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>5</td>
<td>6</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
</div>
EDIT -
Your updated code would look like -
<div align="center" style="height: 350px; overflow: auto; width: 100%;">
<asp:Table ID="tblReport" Font-Size="11px" runat="server" ViewStateMode="Enabled">
<asp:TableHeaderRow Height="30px" ForeColor="#FFFFFF" BackColor="#3b3b3b" Style="font-weight: bold; text-align: left !important; padding-left: 3px; color: #FFF; border-right: 1px solid #ddeaf7;" HorizontalAlign="Center">
</asp:TableHeaderRow>
</asp:Table>
</div>
I have a repeater which has table as per below code and I need to send param to code behind when table row is clicked.
At the moment I am passing it on LinkButton1 click.
I have also tried wrapping in LinkButton but it's not working
How do I do this?
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand" OnItemDataBound="Repeater1_ItemDataBound" OnItemCreated="Repeater1_ItemCreated">
<HeaderTemplate>
<table class="table table-striped table-bordered dttable dataTable no-footer" style="border-style: solid; border-color: rgb(252, 253, 250); text-align: center; font-weight: 700; width: 100%;" id="JsDataTable" role="grid" aria-describedby="JsDataTable_info">
<thead style="width: 100%">
<tr style="color: #fff; width: 100%;">
<td id="tdSr">Sr</td>
<td id="tdCode" style="white-space: nowrap;">
<asp:LinkButton ID="lnCode" runat="server" CommandName="CourseNo" CssClass="linkHeader">Code<i class = "fa fa-fw fa-sort" ></i></asp:LinkButton>
</td>
<td id="tdName" style="width: 50%; white-space: nowrap; text-align: left;">
<asp:LinkButton ID="lnName" runat="server" CommandName="VName" CssClass="linkHeader">Name<i class = "fa fa-fw fa-sort" ></i></asp:LinkButton>
</td>
<td id="tdType" style="width: 20%">
<asp:LinkButton ID="lnType" runat="server" CommandName="VType" CssClass="linkHeader">Type<i class = "fa fa-fw fa-sort" ></i></asp:LinkButton>
</td>
</tr>
</thead>
<tbody style="width: 100%">
</HeaderTemplate>
<ItemTemplate>
<tr id="trID" runat="server" class="box" style="height: 30px; color: #08516F; vertical-align: middle;">
<td style="color: #004457; border-right: 1px solid #004457; vertical-align: middle;" class="labelTxt">
<asp:HiddenField ID="hfAllowSubscription" runat="server" Value='<%#Eval("AllowSubscription") %>' />
<asp:Label ID="lblSR" runat="server"></asp:Label>
</td>
<td style="color: #004457; border-right: 1px solid #004457; vertical-align: middle;">
<%#Eval("CourseNo") %>
</td>
<td style="color: #004457; border-right: 1px solid #004457; text-align: left !important; vertical-align: middle;">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="PlayPrev" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>' CssClass="name"></asp:LinkButton>
</td>
<td style="color: #004457; border-right: 1px solid #004457; vertical-align: middle;">
<asp:Label Text='<%#Eval("VType") %>' runat="server" ID="lblType" CssClass="lblType" Style="font-family: 'Segoe UI semiBold' !important;"></asp:Label>
<span id="lblsubtype" runat="server" class="subtype_color T"></span>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
<div id="repeatorEmptyRow" runat="server" style="text-align: center; color: red;">
No matching records found
</div>
</FooterTemplate>
</asp:Repeater>
I'm guessing you want the value of the CommandArgument in Repeater1_ItemCommand. But if you try to cast the sender to a LinkButton that will not work because the Sender is the Repeater, not the button inside.
So cast the CommandSource and get the correct value.
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
LinkButton lb = e.CommandSource as LinkButton;
Label1.Text = lb.CommandArgument;
}
You cannot bind a tr click directly, so you have to use a trick. You can use jQUery to set the click of the LinkButton to the row itself.
<table border="1" id="Repeater1Table">
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<tr>
<td>Click here</td>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="PlayPrev" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>' CssClass="name"></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<script type="text/javascript">
$(document).ready(function () {
$("#Repeater1Table tr").each(function () {
var href = $(this).find(".name").prop("href").split(":")[1];
$(this).attr("onclick", href);
});
});
</script>
New to using the ListView control and I'm trying to retrieve the value of some textboxes in the layout template. Here's my aspx code:
<asp:ListView
ID="lvFundingSummary"
OnItemCommand="lvFundingSummary_onItemCommand"
OnItemDataBound="lvFundingSummary_ItemDataBound"
runat="server" >
<EmptyDataTemplate>
<table
id="Table1"
runat="server"
style="background-color: #FFFFFF;
border-collapse: collapse;
border-color: #999999;
border-style:none;
border-width:1px;">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr>
<td style="width: 50%; text-align:left; padding-top: 5px; padding-bottom:5px;">
<asp:Label ID="lblResearchArea" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PlName")%>' />
</td>
<td style="width: 30%; text-align:right; padding-top: 5px; padding-bottom:5px;">
<asp:Label ID="lblFundingGross" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FundingGross", "{0:c}")%>' />
</td>
<td style="width: 20%; text-align:right; padding-top: 5px; padding-bottom:5px;">
<asp:Label ID="lblGross" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "AllGross", "{0:c}")%>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" style="width: 90%" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server" width="100%">
<table
ID="itemPlaceholderContainer"
runat="server"
style="width: 98%">
<tr id="TrHeading" runat="server">
<th id="Th1" style="width: 50%; text-align:left;" runat="server">
Research Area</th>
<th id="Th2" style="width: 30%; text-align:right;" runat="server">
Gross</th>
<th id="Th3" style="width: 20%; text-align:right;" runat="server">
All Gross</th>
</tr>
</table>
<div style="overflow-y:scroll; height:400px;">
<table style="border: 10px; width: 100%">
<tr ID="itemPlaceholder" runat="server"></tr>
</table>
</div>
</td>
</tr>
<tr id="Tr2" runat="server">
<td id="Td2" runat="server"
style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
</td>
</tr>
<tr id="TrFooter" runat="server">
<td style="width: 50%; text-align:left;">
<b>Total(s)</b>
</td>
<td id="TdTotal" style="width: 30%; text-align:right;">
<b>
<asp:Label ID="lblTotalFunding" runat="server" /></b>
</td>
<td id="TdTotal" style="width: 20%; text-align:left;">
<b>
<asp:Label ID="lblTotalGross" runat="server" /></b>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
in the lvFundingSummary_PreRender event, I'm trying to access the control as such:
Label lbTotFund = this.lvFundingSummary.FindControl("TrFooter").FindControl("lblTotalFunding") as Label
but that's not working. I know this should be a snap, just can't quite seem to find it.
According to this post, use
var lbTotFund = lvFundingSummary.FindControl("lblTotalFunding") as Label;
in lvFundingSummary_LayoutCreated event, it should do the work
CSS
#outer
{
position: relative;
z-index: 3;
width: 100%;
margin: 0px auto 0 auto;
background: #ffffff;
box-shadow: 0px 0px 60px 0px rgba(0,0,0,0.2);
float:inherit;
}
#main
{
display:inline;
position: relative;
padding: 0px 0px 0px 0px;
width: 100%;
}
#header
{
position: relative;
padding: 28px;
height: 125px;
background: #ffffff;
color: #ffffff;
text-shadow: 2px 2px 2px rgba(0,0,0,0.5);
border-bottom: solid 1px #003B47;
}
#copyright
{
padding: 40px 0 80px 0;
text-align: center;
color: #777777;
}
HTML
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div id="outer">
<div id="header" style="background-color: lightgrey">
</div>
</div>
<div id="main">
<div id="sidebar" style="background-color: lightgrey">
<div id="menubar">
<h2>
Menu
</h2>
<ul class="linkedList">
<li>
<img id="img12" src="./images/bt_tri.gif" alt="" width="16" height="16" runat="server"/>
Server Search
</li>
<li>
<img id="img13" src="./images/bt_tri.gif" alt="" width="16" height="16" runat="server"/>
Service Status
</li>
<li>
<img id="img14" src="./images/bt_tri.gif" alt="" width="16" height="16" runat="server"/>
Data Records
</li>
</ul>
</div>
</div>
<div id="content">
<div class="box">
<h2>
Member Details
</h2>
<p>
<asp:UpdatePanel id="Up1" runat="server">
<contenttemplate>
Last Refreshed : <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><BR /><BR />
<asp:GridView id="gvMem_Details" runat="server" SkinID="Professional" OnRowDataBound="gvMem_Details_RowDataBound">
<RowStyle Width="500px"/>
</asp:GridView>
<asp:Timer ID="Timer1" runat="server" Interval="600">
</asp:Timer>
</contenttemplate>
</asp:UpdatePanel><br class="clear" />
</p>
</div>
<div class="box">
<h2>
Reservation Details
</h2>
<p>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
<contenttemplate>
Last Refreshed : <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><BR /><BR />
<asp:GridView id="gvRes_Details" runat="server" SkinID="Professional" OnRowDataBound="gvRes_Details_RowDataBound">
</asp:GridView>
<asp:Timer ID="Timer2" runat="server" Interval="600">
</asp:Timer>
</contenttemplate>
</asp:UpdatePanel>
</p>
</div>
</div><br class="clear" />
</div><br class="clear" />
</div>
<div id="copyright">
© Company. Design by Technies.
</div>
</form>
I have to stretch my div based on the content inside... i have head, body and copyright(lower) divs... I want body div size should be of its dynamic contents.
I am using the following HTML page to make an accordion control:
<!DOCTYPE >
<html >
<head >
<title></title>
<script language="JavaScript" type="text/javascript" >
function Show() {
document.getElementById("tdfirst").style.display = 'block';
}
function Hide() {
document.getElementById("tdfirst").style.display = 'none';
}
function Show2() {
document.getElementById("tdsecond").style.display = 'block';
}
function Hide2() {
document.getElementById("tdsecond").style.display = 'none';
}
function Show3() {
document.getElementById("tdthird").style.display = 'block';
}
function Hide3() {
document.getElementById("tdthird").style.display = 'none';
}
</script>
<style type="text/css">
.style1 {
width: 164px;
}
.style2
{
height: 98px;
}
.style3
{
width: 110px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr style="border-style: solid; border-width: thin; border-color: inherit;">
<div id="div1" >
<td class="style1"
style="border: thin solid #000000; text-align: right;">
<table><tr><td>Menu1</td><td class="style3">
<img alt="" onclick="Show()" src="Image/down%20arrow.jpg"
style="height: 15px; margin-left: 0px" /><img
alt="" onclick="Hide()" src="Image/up%20arrow.jpg" style="height: 15px" /></td></tr></table> </td>
</div>
</tr>
<tr>
<div id="div2">
<td id="tdfirst" class="style2"
style="border: thin solid #000080; text-align: left;display:none;"; >SubMenu1</td>
</div>
</tr>
</table>
<div>
<table>
<tr style="border-style: solid; border-width: thin; border-color: inherit;">
<div id="div3" >
<td class="style1"
style="border: thin solid #000000; text-align: right;">
<table><tr><td>Menu2</td><td class="style3">
<img alt="" onclick="Show2()" src="Image/down%20arrow.jpg"
style="height: 15px; margin-left: 0px" /><img
alt="" onclick="Hide2()" src="Image/up%20arrow.jpg" style="height: 15px" /></td></tr></table> </td>
</div>
</tr>
<tr>
<div id="div4">
<td id="tdsecond" class="style2"
style="border: thin solid #000080; text-align: left;display:none;"; >SubMenu2</td>
</div>
</tr>
</table>
<table>
<tr style="border-style: solid; border-width: thin; border-color: inherit;">
<div id="div5" >
<td class="style1"
style="border: thin solid #000000; text-align: right;">
<table><tr><td>Menu3</td><td class="style3">
<img id="imgdown" alt="" onclick="Show3()" src="Image/down%20arrow.jpg"
style="height: 15px; margin-left: 0px" /><img id="imgup"
alt="" onclick="Hide3()" src="Image/up%20arrow.jpg" style="height: 15px" /></td></tr></table> </td>
</div>
</tr>
<tr>
<div id="div6">
<td id="tdthird" class="style2"
style="border: thin solid #000080; text-align: left;display:none;"; >SubMenu3</td>
</div>
</tr>
</table>
</div>
</form>
</body>
</html>
When I try to display this HTML in a WebBrowser control, nothing appears and the control is blank.
XAML:
<phone:WebBrowser HorizontalAlignment="Left" Margin="0" VerticalAlignment="Top" x:Name="webBrowser1" Grid.Row="1" IsScriptEnabled="True" />
.cs:
webBrowser1.Navigate(new Uri("/Html_Pages/AboutUs.html", UriKind.Relative));
Can anyone see what I'm doing wrong? I'm using VS2012 and the WP8 emulator.
Hope This will help you. NavigateToString()
private void goNavigateToStringButton_Click(object sender, RoutedEventArgs e)
{
// Load HTML document as a string
Uri uri = new Uri(#"pack://application:,,,/HTMLDocumentWithoutScript.html", UriKind.Absolute);
Stream stream = Application.GetResourceStream(uri).Stream;
using (StreamReader reader = new StreamReader(stream))
{
// Navigate to HTML document string
this.webBrowser.NavigateToString(reader.ReadToEnd());
}
}
from : NavigateToString() method