bootstrap popover in asp.net webform - asp.net

i would like to try bootstrap pop over using asp.net
ive already tried and search for the ways to do this
function pageLoad(sender, args) {
$('[data-toggle="popover"]').popover({
html: true,
placement: "bottom",
content: function () {
return $('#PopoverConditionMasterPart').html();
}
});
};
but still there's no clear sign for popover.
and in my debugger i see errors like $ is not defined and .popover is not a function
another problem is most of the tutorial is in MVC
can someone give me advise or better explanation to do this.
Thanks in advance and keep going!
here is my current work:
css:
<asp:Content ID="Content2" ContentPlaceHolderID="css" runat="server">
<link href="Content/bootstrap.css" rel="stylesheet" />
</asp:Content>
html:
<asp:Content ID="Content3" ContentPlaceHolderID="body" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div class="row">
<div class="col-md-2 col-lg-2">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label runat="server" data-toggle="popover" data-placement='bottom' title="sample" ID="lblConditionMasterPart" CssClass="form-control popover PopoverConditionMasterPart" Text="click me" Style="cursor: pointer;"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel9" runat="server">
<ContentTemplate>
<div id="PopoverConditionMasterPart" style="display: none;">
<button type= "button" title="bnt1" class="form-control btn btn-secondary"> btn1</button>
<button type= "button" title="bnt1" class="form-control btn btn-primary"> btn2</button>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</asp:Content>
script:
<asp:Content ID="Content4" ContentPlaceHolderID="script" runat="server">
<script src="Scripts/jquery-3.2.1.js" type="text/javascript"></script>
<script src="Scripts/bootstrap.js" type="text/javascript"></script>
<script type="text/javascript">
function pageLoad(sender, args) {
$('[data-toggle="popover"]').popover({
html: true,
placement: "bottom",
content: function () {
return $('#PopoverConditionMasterPart').html();
}
});
};
</script>
</asp:Content>

It appears you are defining a pageLoad function but never calling it. You could call it in ready, but why not just do what the function does on page load:
<script type="text/javascript">
$(document).ready(
$('[data-toggle="popover"]').popover({
html: true,
placement: "bottom",
content: function () {
return $('#PopoverConditionMasterPart').html();
}
});
});
</script>

Related

ASP.NET Controls in UpdatePanel not working after File Upload

I'm new to working with the AJAX UpdatePanel and I've tried searching for an answer to this question and haven't found a solution yet.
I have multiple controls in an UpdatePanel since I am hiding and showing panels based on different button clicks. Also inside the UpdatePanel is a FileUpload control. Everything works fine until I upload a file. After that, none of the controls, like buttons or radio button lists, or JQuery scripts, like a datepicker, fire in the UpdatePanel after the upload.
Here is the aspx code:
<%# Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="Site.Admin" %>
<%# MasterType virtualPath="~/Site1.master"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.12.4.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript" src="scripts/jquery-ui-timepicker-addon.js"></script>
<link rel="stylesheet" href="Content/jquery-ui-timepicker-addon.css">
<script type="text/javascript">
function pageLoad() {
$(function () {
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
$('.picker').datetimepicker();
}
});
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"></asp:ScriptManager>
<asp:UpdatePanel ID="adminUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="True" runat="server">
<ContentTemplate>
<div class="form-group">
<div class='input-group date' id='datetimepicker3'>
<asp:TextBox ID="tb_EndDate" class="form-control picker" runat="server"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<div class="form-group">
<asp:RadioButtonList ID="rbl_Active" runat="server" OnSelectedIndexChanged="rbl_Active_SelectedIndexChanged" RepeatDirection="Horizontal" CellPadding="4" CellSpacing="4" AutoPostBack="True">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList>
</div>
<div class="form-group">
<label>Upload Photo</label>
<asp:FileUpload ID="imageFileUpload" runat="server" />
<asp:Button class="btn btn-primary" ID="btn_UploadImg" runat="server" Text="Upload Image" OnClick="btn_UploadImg_Click" CausesValidation="False" />
<asp:Button ID="btn_CancelImg" OnClick="btn_CancelImg_Click" class="btn btn-primary" runat="server" Text="Change/Remove Image" CausesValidation="False" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
And the code behind relating to the file upload:
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btn_UploadImg);
}
protected void btn_UploadImg_Click(object sender, EventArgs e)
{
bool isUploaded = uploadImage(imageFileUpload);
if (isUploaded)
{
btn_CancelImg.Visible = true;
}
}
I'm not sure what I'm doing wrong. It worked fine when run from Visual Studio, but when pushed to the server it all fails
Instead of setting Visible to true/false, can you please try:
<asp:Panel ID="pnlToHide" runat="server" style="display:none">
When you have to show, you can use the following:
protected void btnShow_Click(object sender, EventArgs e)
{
pnlToHide.Attributes["style"] = "display: '';";
}
Also, you can try fullpostback/render by using:
<Triggers>
<asp:PostBackTrigger ControlID="btnFileUpload"/>
</Triggers>

bootstrap js not loading asp.net webform

<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script>
$("button").click(function () {
alert("funny");
var $btn = $(this);
$btn.button('loading');
// Then whatever you actually want to do i.e. submit form
// After that has finished, reset the button state using
setTimeout(function () {
$btn.button('reset');
}, 1000);
});
</script>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">#</span>
<asp:TextBox ID="TextBox1" runat="server" Text="1" class="form-control" placeholder="Username" aria-describedby="basic-addon1"></asp:TextBox>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" class="btn btn-default" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" ></asp:Label>
</form>
<button type="button" data-loading-text="Loading..." class="btn btn-primary">
Loading state
</button>
</body>
</html>
this is my simple code..
i have confirmed that jquery should load first then bootstrap.. still its not loading

Colorbox + ASP.NET WebForm Submit Button

I am having trouble using a Colorbox with an ASP.NET WebForm inside. What I am trying to do is:
User clicks a link, and the colorbox pops up
Inside colorbox, user enters a term in a textbox and clicks submit button
On submit, the page hits the DB and then shows results (still inside the colorbox)
Right now, I have steps #1 & #2 working, but #3 isn't. If I click the submit button, the browser navigates to the page that was loaded inside the colorbox (FAQ.aspx).
Test.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test Page</title>
<link href="css/colorbox.css" rel="stylesheet" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.colorbox.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<a class="cbox">FAQs</a>
</div>
</form>
<script>
$(document).ready(function () {
var colorbox = $("#colorbox");
$('form#Form1').prepend(colorbox);
});
$('a.cbox').colorbox({ href: "FAQ.aspx" });
</script>
</body>
</html>
FAQ.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Frequently Asked Questions</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Search: <asp:TextBox runat="server" ID="txtSearch" /> <asp:Button runat="server" ID="btnSubmitSearch" Text="Submit" OnClick="btnSubmitSearch_Click"/>
<br />
<asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Literal ID="litOutput" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmitSearch" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<br />
</div>
</form>
</body>
</html>
Can anyone help me figure out what I'm doing wrong?
You have to load the colorbox content inside an iframe:
$('a.cbox').colorbox({ href: "FAQ.aspx", iframe: true, width: 456, height: 100 });

compare jquery datepicker with date in database in asp.net

I am newbie. I am working on asp.net website. I have added datepicker and it works fine. Now I want to get that date and compare it with date in my database. But I have no idea of how to do it. I also goggled but couldn't find any solution.
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="reserve" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript">
$(document).ready(function () {
$('#coin-slider').coinslider();
});
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="jquery.datepick.js"></script>
<script type="text/javascript">
$(function () {
$('#popupDatepicker').datepick();
});
function showDate(date) {
alert('The date chosen is ' + date);
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<input type="text" id="popupDatepicker" />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<div id='coin-slider' >
<a target="_blank"> </a>
<a>
<img id="Img2" src="~/Images/ar1.jpg" alt="header1" height="120" runat="server" style="width: 110px"/>
<img id="Img3" src="~/Images/ar2.jpg" alt="header1" height="120" runat="server" style="width: 110px"/>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</a>
</div>
</asp:Content>
Use DateTime.Compare(Date1, Date2) in code behind.
it'll give you differnce between the datetimes. Is this what you looking for

how we can get html control if any which are placed inside RadEditor

I want to find out how we can get html control if any which are placed inside RadEditor and replace that value. I have try this way to change the Image source.
<script type="text/javascript">
function getEditor()
{
editor = $find("<%=reFormEditor.ClientID%>"); //return a reference to RadEditor
var image = editor.get_document().body.document.getElementById("Image1");
}
Here is my aspx:
<telerik:RadEditor runat="server" ID="reFormEditor">
<Content>
<asp:Button ID="btnSubmit2" runat="server" Text="Submit"/>
<img id="Image1" src="../Images/tabSelected.jpg" />
</Content>
</telerik:RadEditor>
I want to change the Image source when textbox keydown. Help me how to resolve this issue.
Here is the code, and you can't put button inside contents it must be outside of editor contents :
<body>
<script type="text/javascript">
function replaceImage() {
var editor = $find("<%= reFormEditor.ClientID %>");
var oDocument = editor.get_document()
var img = oDocument.getElementById('imageInContents');
img.src = '/image2.png';
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="mika" runat="server"></asp:ScriptManager>
<telerik:RadEditor runat="server" ID="reFormEditor">
<Content>
<img id="imageInContents" src="/image1.png" />
</Content>
</telerik:RadEditor>
<input type="button" onclick="replaceImage()" value="Replace Image" />
</form>
</body>
And here is an example with text change
<body>
<script type="text/javascript">
function replaceSpanText() {
var editor = $find("<%= reFormEditor.ClientID %>");
var oDocument = editor.get_document()
var spn = oDocument.getElementById('span1');
spn.innerHTML = 'Text 2';
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="mika" runat="server"></asp:ScriptManager>
<telerik:RadEditor runat="server" ID="reFormEditor">
<Content>
<span id="span1">Text 1</span>
</Content>
</telerik:RadEditor>
<input type="button" onclick="replaceSpanText()" value="Replace text" />
</form>
</body>

Resources