Why are InnerHtml, InnerText and property values empty on postback? - asp.net

I have some spans on my page that have value attributes.
When i try to get these attributes from the code behind, i only get the first two - the rest are null, even if the the value attributes exist and are not empty.
Howcome? This is my markup:
<div class="ExtraContainer">
<div class="box_slider">
<form id="Form1" runat="server">
<div class="block block1">
<h3>
Vælg områder</h3>
<div class="wraper">
<input id="chkAllAreas" type="radio" name="group1" class="input_radio" runat="server"/>
<label for="chkAllAreas">
Vis alle områder</label>
</div>
<div class="wraper">
<input id="chkCustomAreas" type="radio" name="group1" class="input_radio" runat="server"/>
<label for="chkCustomAreas">
Vælg områder</label>
</div>
</div>
<div class="block block2">
<h3>
Vælg Ledighed</h3>
<div class="wraper">
<input id="chkShowAll" type="radio" name="group2" class="input_radio" runat="server" />
<label for="chkShowAll">
Vis alle boliger</label>
</div>
<div class="wraper">
<input id="chkIsAvailable" type="radio" name="group2" class="input_radio" runat="server" />
<label for="chkIsAvailable">
Vis kun ledige boliger</label>
</div>
</div>
<div class="block block3">
<h3>
Vælg boligtype</h3>
<div class="wraper go_left">
<input id="chkAllTHousingTypes" type="checkbox" class="input_check" runat="server" />
<label for="chkAllTHousingTypes">
Vis alle boligtyper</label>
</div>
<div class="wraper go_left">
<input id="chkFamilieboliger" type="checkbox" class="input_check" runat="server" />
<label for="chkFamilieboliger">
Familieboliger</label>
</div>
<div class="wraper go_left">
<input id="chkUngdomsboliger" type="checkbox" class="input_check" runat="server" />
<label for="chkUngdomsboliger">
Ungdoms- & studieboliger</label>
</div>
<div class="wraper go_left">
<input id="chkAeldrebolig" type="checkbox" class="input_check" runat="server" />
<label for="chkAeldrebolig">
Senior- & ældreboliger</label>
</div>
</div>
<div class="clear">
</div>
<div class="line">
</div>
<div class="block4 go_left">
<h3>
Vælg økonomi</h3>
<div class="slider_info">
<div class="slider_info_leftright_container">
<div class="slider_info_left">
<span>Husleje</span>
</div>
<div class="slider_info_right" style="float: right">
<span id="huslejefra" runat="server"></span> <em>til</em> <span id="huslejetil" runat="server"></span><span>kr</span>
</div>
</div>
<div class="Slider">
<div id="husleje-slider-range">
</div>
</div>
</div>
<div class="slider_info">
<div class="slider_info_leftright_container">
<div class="slider_info_left">
<span>Indskud</span>
</div>
<div class="slider_info_right" style="float: right">
<span id="indskudfra" runat="server"></span> <em>til</em> <span id="indskudtil" runat="server"></span><span>m2</span>
</div>
<div class="Slider">
<div id="indskud-slider-range">
</div>
</div>
</div>
</div>
</div>
<div class="block4 go_right">
<h3>
Vælg størrelse</h3>
<div class="slider_info">
<div class="slider_info_leftright_container">
<div class="slider_info_left">
<span>Antal værelser</span>
</div>
<div class="slider_info_right" style="float: right">
<span id="rumfra" runat="server">3</span> <em>til</em> <span id="rumtil"
runat="server">6</span><span>rum</span>
</div>
</div>
<div class="Slider">
<div id="rum-slider-range">
</div>
</div>
</div>
<div class="slider_info">
<div class="slider_info_leftright_container">
<div class="slider_info_left">
<span>m2</span>
</div>
<div class="slider_info_right" style="float: right">
<span id="storrelsefra" value="2" runat="server"></span> <em>til</em> <span id="storrelsetil" runat="server"></span><span>m2</span>
</div>
</div>
<div class="Slider">
<div id="storrelse-slider-range">
</div>
</div>
</div>
</div>
<asp:Button ID="searchButton" OnClick="ImgSearch_Click" Text="Søg" runat="server" />
</form>
<div class="clear">
</div>
</div>
<div class="block5">
<h3>
Vælg resultatvisning</h3>
<div class="buttonswrapper">
<div class="wraper">
<input id="id9" type="radio" class="input_radio" />
<label for="id9">
Billedevisning</label>
</div>
<div class="wraper">
<input id="id10" type="radio" class="input_radio" />
<label for="id10">
Kortvisning</label>
</div>
</div>
<a class="link_img resetBtn" href="#">
<img src="style/images/select_img.png" alt="" />Nulstil søgningen</a>
</div>
<div class="clear"> </div>
<input id="HDSelectedAreas" type="hidden" runat="server" class="HSelectedArea" />
</div>
the search button looks like this in the aspx:
<asp:Button ID="searchButton" OnClick="ImgSearch_Click" Text="Søg" runat="server" />
And this is the code behind:
protected void ImgSearch_Click(object sender, EventArgs e)
{
String cRoomsFrom = rumfra.Attributes["value"];
String cRoomsTo = rumtil.Attributes["value"];
String cSizeFrom = storrelsefra.Attributes["value"];
String cSizeTo = storrelsetil.Attributes["value"];
String cRentFrom = huslejefra.Attributes["value"];
String cRentTo = huslejetil.Attributes["value"];
String cDepositFrom = indskudfra.Attributes["value"];
String cDepositTo = indskudtil.Attributes["value"];
}
to initialize the values:
<script type="text/javascript" language="javascript">
function setupSlider(min, max, step, values, sliderElement, minelement, maxelement) {
$(sliderElement).slider({
range: true,
min: min,
max: max,
values: values,
step: step,
slide: function (event, ui) {
$(minelement).html(ui.values[0]);
$(maxelement).html(ui.values[1]);
$(minelement).attr('value', ui.values[0]);
$(maxelement).attr('value', ui.values[1]);
__doPostBack();
}
});
$(minelement).html($(sliderElement).slider("values", 0));
$(maxelement).html($(sliderElement).slider("values", 1));
$(minelement).attr('value', $(sliderElement).slider("values", 0));
$(maxelement).attr('value', $(sliderElement).slider("values", 1));
}
function initializeSliders()
{
// størrelse slider
var values = [10, 80];
setupSlider(10, 80, 10, values, "#storrelse-slider-range", "#storrelsefra", "#storrelsetil");
// husleje slider
values = [1000, 7000];
setupSlider(1000, 12000, 1000, values, "#husleje-slider-range", "#huslejefra", "#huslejetil");
/// rum
values = [3, 6];
setupSlider(1, 8, 1, values, "#rum-slider-range", "#rumfra", "#rumtil");
// indskud
values = [3000, 7000];
setupSlider(1000, 10000, 1000, values, "#indskud-slider-range", "#indskudfra", "#indskudtil");
//fix color
fixToolTipColor();
}
$(document).ready(function () {
$('.Udvidet').live('click', function () {
$('.UdvidetSoegning').toggle('slow');
});
$(function () {
initializeSliders();
$(".resetBtn").live("click", function () {
initializeSliders();
__doPostBack();
});
});
});
</script>
I tried changing to InnerHtml and InnerText, but the result is the same. Sometimes the value property is null, but then InnerHtml or InnerText return the actual value :S

On post back only the input elements are posted.
So they are the same as before the post back, what they have before the post back, have and now. So actually you do not "get" this parameters on code behind, you only "set" them and on server controls with viewstate on, you can remember this parametres on post back - but you can not change them on client side and expect to read this change on server.
Here the workaround is. Ether use the viewstate of the page to save some values and keep them on post back, ether use input hidden elements to have them on post back.

Related

PagedList loses its values because it keeps invoking httpGet method

I have the following code which shows that I am using PagedList to display my search result in a paged order. The problem with it is that at the first result of the search it shows the number of pages related to the search result but once I click on the next page it keeps invoking the method of the page list in the HttpGet rather than keeping browsing the result that came from the the HttpPost method. How can I fix this
Controller:
public ActionResult SearchResult(int? page)
{
var result = from app in db.AllJobModel select app;
return View(result.ToList().ToPagedList(page ?? 1,5));
}
[HttpPost]
public ActionResult SearchResult(string searchTitle, string searchLocation, int? page)
{
setUpApi(searchTitle, searchLocation);
//setUpApi(searchTitle);
var result = db.AllJobModel.Where(a => a.JobTitle.Contains(searchTitle) && a.locationName.Contains(searchLocation));
return View(result.ToList().ToPagedList(page ?? 1, 5));
}
View :
#using (Html.BeginForm("SearchResult", "Home", FormMethod.Post))
{
<div class="job-listing-section content-area">
<div class="container">
<div class="row">
<div class="col-xl-4 col-lg-4 col-md-12">
<div class="sidebar-right">
<!-- Advanced search start -->
<div class="widget-4 advanced-search">
<form method="GET" class="informeson">
<div class="form-group">
<label>Keywords</label>
<input type="text" name="searchTitle" class="form-control selectpicker search-fields" placeholder="Search Keywords">
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="searchLocation" class="form-control selectpicker search-fields" placeholder="Location">
</div>
<br>
<a class="show-more-options" data-toggle="collapse" data-target="#options-content5">
<i class="fa fa-plus-circle"></i> Date Posted
</a>
<div id="options-content5" class="collapse">
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox15" type="checkbox">
<label for="checkbox15">
Last Hour
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox16" type="checkbox">
<label for="checkbox16">
Last 24 Hours
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox17" type="checkbox">
<label for="checkbox17">
Last 7 Days
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox18" type="checkbox">
<label for="checkbox18">
Last 30 Days
</label>
</div>
<br>
</div>
<a class="show-more-options" data-toggle="collapse" data-target="#options-content">
<i class="fa fa-plus-circle"></i> Offerd Salary
</a>
<div id="options-content" class="collapse">
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox2" type="checkbox">
<label for="checkbox2">
10k - 20k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox3" type="checkbox">
<label for="checkbox3">
20k - 30k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox4" type="checkbox">
<label for="checkbox4">
30k - 40k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox1" type="checkbox">
<label for="checkbox1">
40k - 50k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox7" type="checkbox">
<label for="checkbox7">
50k - 60k
</label>
</div>
<br>
</div>
<input type="submit" value="Update" class="btn btn-success" />
</form>
</div>
</div>
</div>
<div class="col-xl-8 col-lg-8 col-md-12">
<!-- Option bar start -->
<div class="option-bar d-none d-xl-block d-lg-block d-md-block d-sm-block">
<div class="row">
<div class="col-lg-6 col-md-7 col-sm-7">
<div class="sorting-options2">
<span class="sort">Sort by:</span>
<select class="selectpicker search-fields" name="default-order">
<option>Relevance</option>
<option>Newest</option>
<option>Oldest</option>
<option>Random</option>
</select>
</div>
</div>
<div class="col-lg-6 col-md-5 col-sm-5">
<div class="sorting-options">
<i class="fa fa-th-list"></i>
<i class="fa fa-th-large"></i>
</div>
</div>
</div>
</div>
#foreach (var item in Model)
{
<div class="job-box">
<div class="company-logo">
<img src="~/JobImageUploads/#Html.DisplayFor(modelItem => item.UniqueJobImageName)" alt="logo">
</div>
<div class="description">
<div class="float-left">
<h5 class="title">#item.JobTitle</h5>
<div class="candidate-listing-footer">
<ul>
<li><i class="flaticon-work"></i>#Html.DisplayFor(modelIem => item.maximumSalary)</li>
<li><i class="flaticon-time"></i>#Html.DisplayFor(modelIem => item.maximumSalary)</li>
<li><i class="flaticon-pin"></i>#Html.DisplayFor(modelIem => item.locationName)</li>
</ul>
<h6>Deadline: Jan 31, 2019</h6>
</div>
<div>
#item.JobDescription
</div>
</div>
<div class="div-right">
#Html.ActionLink("Details", "Details", new { id = item.Id }, new { #class = "apply-button" })
Details
<i class="flaticon-heart favourite"></i>
</div>
</div>
</div>
}
</div>
</div>
</div>
</div>
<div class="pagining">
#Html.PagedListPager(Model, page => Url.Action("SearchResult", new
{ page }))
</div>
}
One solution to preserve browsing results would be to pass searchTitle and searchLocation to your SearchResult GET method as well and keep them in the ViewBag to persist search results on paging.
This is because the PagedList helper uses a Url.Action which invokes the the SearchResults GET request.
EDIT: upon further testing, I would do away with the post method all together and change your form to use the GET method for everything. I have updated the code to reflect this approach.
public ActionResult SearchResult(int? page, string searchTitle = null, string searchLocation = null)
{
ViewBag.searchTitle = searchTitle;
ViewBag.searchLocation = searchLocation;
ViewBag.page = page;
var result = new List<Job>(); //replace with AllJobModel class
if(!string.IsNullOrEmpty(ViewBag.searchTitle) || !string.IsNullOrEmpty(ViewBag.searchTitle))
{
setUpApi(searchTitle, searchLocation);
//setUpApi(searchTitle);
result = db.AllJobModel.Where(a => a.JobTitle.Contains(searchTitle) && a.locationName.Contains(searchLocation));
}
else
{
result = from app in db.AllJobModel select app;
}
return View(result.ToList().ToPagedList(page ?? 1, 5));
}
and then in your view, set the values (if any) in the searchTitle and searchLocation text boxes. Also add them to the pagedList helper so the values persist on paging.
Edit: Also gonna need to add a hidden field to persist the page value on searches.
#using (Html.BeginForm("SearchResult", "Home", FormMethod.Get))
{
<input type="hidden" name="page" value="#ViewBag.page">
<div class="job-listing-section content-area">
<div class="container">
<div class="row">
<div class="col-xl-4 col-lg-4 col-md-12">
<div class="sidebar-right">
<!-- Advanced search start -->
<div class="widget-4 advanced-search">
<form method="GET" class="informeson">
<div class="form-group">
<label>Keywords</label>
<input type="text" name="searchTitle" class="form-control selectpicker search-fields" placeholder="Search Keywords" value="#ViewBag.searchTitle">
</div>
<div class="form-group">
<label>Location</label>
<input type="text" name="searchLocation" class="form-control selectpicker search-fields" placeholder="Location" value="#ViewBag.searchLocation">
</div>
<br>
<a class="show-more-options" data-toggle="collapse" data-target="#options-content5">
<i class="fa fa-plus-circle"></i> Date Posted
</a>
<div id="options-content5" class="collapse">
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox15" type="checkbox">
<label for="checkbox15">
Last Hour
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox16" type="checkbox">
<label for="checkbox16">
Last 24 Hours
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox17" type="checkbox">
<label for="checkbox17">
Last 7 Days
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox18" type="checkbox">
<label for="checkbox18">
Last 30 Days
</label>
</div>
<br>
</div>
<a class="show-more-options" data-toggle="collapse" data-target="#options-content">
<i class="fa fa-plus-circle"></i> Offerd Salary
</a>
<div id="options-content" class="collapse">
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox2" type="checkbox">
<label for="checkbox2">
10k - 20k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox3" type="checkbox">
<label for="checkbox3">
20k - 30k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox4" type="checkbox">
<label for="checkbox4">
30k - 40k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox1" type="checkbox">
<label for="checkbox1">
40k - 50k
</label>
</div>
<div class="checkbox checkbox-theme checkbox-circle">
<input id="checkbox7" type="checkbox">
<label for="checkbox7">
50k - 60k
</label>
</div>
<br>
</div>
<input type="submit" value="Update" class="btn btn-success" />
</form>
</div>
</div>
</div>
<div class="col-xl-8 col-lg-8 col-md-12">
<!-- Option bar start -->
<div class="option-bar d-none d-xl-block d-lg-block d-md-block d-sm-block">
<div class="row">
<div class="col-lg-6 col-md-7 col-sm-7">
<div class="sorting-options2">
<span class="sort">Sort by:</span>
<select class="selectpicker search-fields" name="default-order">
<option>Relevance</option>
<option>Newest</option>
<option>Oldest</option>
<option>Random</option>
</select>
</div>
</div>
<div class="col-lg-6 col-md-5 col-sm-5">
<div class="sorting-options">
<i class="fa fa-th-list"></i>
<i class="fa fa-th-large"></i>
</div>
</div>
</div>
</div>
#foreach (var item in Model)
{
<div class="job-box">
<div class="company-logo">
<img src="~/JobImageUploads/#Html.DisplayFor(modelItem => item.UniqueJobImageName)" alt="logo">
</div>
<div class="description">
<div class="float-left">
<h5 class="title">#item.JobTitle</h5>
<div class="candidate-listing-footer">
<ul>
<li><i class="flaticon-work"></i>#Html.DisplayFor(modelIem => item.maximumSalary)</li>
<li><i class="flaticon-time"></i>#Html.DisplayFor(modelIem => item.maximumSalary)</li>
<li><i class="flaticon-pin"></i>#Html.DisplayFor(modelIem => item.locationName)</li>
</ul>
<h6>Deadline: Jan 31, 2019</h6>
</div>
<div>
#item.JobDescription
</div>
</div>
<div class="div-right">
#Html.ActionLink("Details", "Details", new { id = item.Id }, new { #class = "apply-button" })
Details
<i class="flaticon-heart favourite"></i>
</div>
</div>
</div>
}
</div>
</div>
</div>
</div>
<div class="pagining">
#Html.PagedListPager(Model, page => Url.Action("SearchResult", new
{ page, searchTitle = ViewBag.searchTitle, searchLocation = ViewBag.SearchLocation }))
</div>
}
I know this is a slight change to your original design, so please let me know if you'd like to discuss it further.
Hope this helps you!

Setting error message to right side of control bootstrap and Angular Js

I am using Angular js, in which i have the below control.
<body class="ng-cloak">
<div ng-controller="testController" ng-init="init()">
<form name="mainForm" id="createForm" ng-submit="mainForm.$valid && add()" novalidate="">
<div class="container form-horizontal" ng-show="createMenu">
<br />
<div class="form-group">
<label for="firstName" class="col-sm-3 control-label">Name<em style="color:red">*</em></label>
<div class="col-sm-4">
<input type="text" maxlength="150" class="form-control" required="" ng-model="nName" id="nName" name="nName" />
</div>
<div class="col-sm-3">
<span class="error" ng-show="submitted == true && mainForm.nName.$error.required">Please enter Name.</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Recipient Group:<em style="color:red">*</em></label>
<div class="input-group col-sm-4" style="padding-left:10px;">
<span class="input-group-addon">
<i class="glyphicon glyphicon-search"></i>
</span>
<input type="text" class="form-control" required="" placeholder="Search the group" ng-model="searchDatalocation" ng-change="searchgroups()" name="searchValue">
</div>
<div class="col-sm-3">
<span class="error" ng-show="submitted == true && mainForm.searchValue.$error.required">Please select a Recipient group.</span>
</div>
</div>
</form>
</div>
</body>
The error message "Please enter Name" appears on right side of the textbox, however, the error message "Please select a Recipient group" appers below the control. I have tried changing the css, but it has not worked. How to set the error message to be shown on right side after the control.
Thanks
Style the .input-group div with display: inline-table; and float:left;
Please also note that there is one missing closing tag </div> for class="container form-horizontal"

Need to create a report using report viewer

I need to create a report using Report viewer. unfortunately, I haven't worked on Report viewer before. My SQL query accepts 3 parameters to fetch the data from SQL server. Query would be:
Select col1,col2,col3 from table1 where area='ddlselectedarea' and start_date='01-01-2016' and end_date='31-01-2016'
My UI would be:
<section id="content" class="has-btn-bar-btm-fixed"><!-- content -->
<form runat="server" class="form-horizontal custom-form row">
<div class="cost-transfer-block"><!-- cost-transfer-block -->
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-lg-10">
<h2>Dump by item</h2>
<div class="col-md-6">
<div class="form-group">
<asp:label runat="server" Text="From Site" ID="lblFromSite" class="control-label col-sm-3 col-md-3 col-lg-3" ></asp:label>
<div class="col-sm-9">
<div class="input-group">
<select class="form-control">
<asp:DropDownList ID="DdlFromsite" runat="server" ></asp:DropDownList>
</select>
<span class="input-group-addon"> </span>
</div>
</div>
</div>
</div>
<div class="col-md-6 cst-brd-left">
<div class="form-group">
<asp:label runat="server" Text="From Date" ID="lblFromDate" class="control-label col-sm-3 col-md-3 col-lg-3" ></asp:label>
<div class="col-sm-9 transferdate">
<div class="input-group date">
<input type="date" class="form-control" id="" placeholder="Select Date" >
<span class="input-group-addon"><img src="images/icon-add-on-2-date.png" alt="" /></span>
</div>
</div>
</div>
<div class="form-group">
<asp:label runat="server" Text="To Date" ID="lblToDate" class="control-label col-sm-3 col-md-3 col-lg-3" >To Date</asp:label>
<div class="col-sm-9 transferdate">
<div class="input-group date">
<input type="date" class="form-control" id="" placeholder="Select Date" >
<span class="input-group-addon"><img src="images/icon-add-on-2-date.png" alt="" /></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4 col-lg-2">
</div>
</div>
</div>
</div>
<!-- /cost-transfer-block -->
<%--<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"></rsweb:ReportViewer>--%>
<div class="gray-btn-row clearfix">
<div class="btns-group">
<asp:button runat="server" Text="Enter" ID="btnEnter" class="btn btn-dark-blue"></asp:button>
</div>
</div>
</form>
</section>
Please guide me in designing a report using the reportviewer
The report viewer is a totally new component which needed to be designed using Report viewer or report viewer wizard. You can add any of them from the Add new items pane and bind a data table to that component.
I hope this helps others

fetching and populating values in bootstrap modal popup

This is what I'm trying to achieve here. The user clicks on a button and the bootstrap modal popup appears. The user enters the event id value in the text box of the modal popup and I want information regarding the event to be displayed on the other fields in the modal popup.
I wrote a function under txtEventId_TextChanged event and I was able to get the value entered in the event id textbox. I was able to pass that value to the database and retrieve it's corresponding values from database as well.
My problem now is that I'm not able to display those data in the modal popup.
Here is the HTML Code :
<!-- Maintainenance Modal -->
<div class="modal fade" id="maintenanceModal" role="dialog" tabindex = -1 aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="false">
<div class="modal-dialog">
<!-- Maintaineance Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Maintain Event</h4>
</div>
<div class="row">
<div class="col-xs-2">
<div class ="form-group">
<label for="eventID" id="lblEventId">EventID</label>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<asp:TextBox ID="txtEventId" runat="server" CssClass="form-control dialogtextbox" AutoPostBack="false" OnTextChanged="txtEventId_TextChanged"></asp:TextBox>
</div>
</div>
</div>
<asp:HiddenField ID="HiddenField1" runat="server" />
<div class="modal-body">
<div class="EventsIcons">
<div class ="form-group">
<label for="MaintainDropDown" id="MaintainEventLabel">Select The Event Type </label>
<select id="MaintainDropDown" runat="server" class="btn btn-default dropdown-toggle eventdropdown" data-toggle="dropdown" aria-expanded="true">
<option value="WorkAnniversary">WORKANNIVERSARY</option>
<option value="Birthday">BIRTHDAY</option>
<option value="Community">COMMUNITY</option>
<option value="FoodSafety">FOOD SAFETY</option>
<option value="Health&Safety">HEALTH & SAFETY</option>
<option value="Holiday">HOLIDAY</option>
<option value="Maintenance">MAINTENANCE</option>
<option value="QualityAudit">QUALITY AUDIT</option>
<option value="SocialEvent">SOCIAL EVENT</option>
<option value="Stat-Holiday">STAT-HOLIDAY</option>
<option value="Sustainability">SUSTAINABILITY</option>
<option value="TownHall">TOWN HALL</option>
<option value="Visitor">VISITOR</option>
<option value="Wellness">WELLNESS</option>
</select>
</div>
</div>
<div class="Description">
<label for="description" id="MaintainDescription">Description</label>
<textarea class="form-control" rows="5" id="maintainTxtDescription" name="eventdescription" runat="server"></textarea>
</div>
<div class="row">
<div class="col-xs-2">
<div class="form-group">
<label id="Label3">Start Time</label>
</div>
</div>
<div class='col-xs-6'>
<div class="form-group">
<div class='input-group date' id="maintainStartDate">
<asp:TextBox ID="maintainTxtStartDate" runat="server" CssClass="form-control dialogtextbox"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="form-group">
<div class="input-group date" id="startTime">
<asp:TextBox ID="maintainTxtStartTime" runat="server" CssClass="form-control dialogtextbox"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-2">
<div class="form-group">
<label id="Label4">End Time</label>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<div class="input-group date" id="endDate">
<asp:TextBox ID="maintainTxtEndDate" runat="server" CssClass="form-control dialogtextbox"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="form-group">
<div class="input-group date" id="endTime">
<asp:TextBox ID="maintainTxtEndTime" runat="server" CssClass="form-control dialogtextbox"></asp:TextBox>
<span class="input-group-addon">
<span class="glyphicon glyphicon-time"></span>
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-offset-1 col-xs-6">
<div class="form-group">
<asp:CheckBox ID="maintainChkBoxAllDayEvents" runat="server" CssClass="checkbox" Text="All Day Event" OnClick="document.getElementById('maintainTxtStartTime').disabled = this.checked;document.getElementById('maintainTxtEndTime').disabled = this.checked;" />
</div>
</div>
<div class="col-xs-offset-1 col-xs-4">
<div class="form-group">
<asp:Button ID="btnMaintainSubmit" runat="server" Text="SUBMIT"
CssClass="btn btn-group-justified btn-success" />
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
And here is my code behind code.
protected void txtEventId_TextChanged(object sender, EventArgs e)
{
BusinessLogicLayer BL = new BusinessLogicLayer();
EventId = Convert.ToInt32(txtEventId.Text);
try
{
DataTable dt = BL.BLGetEventDetails(EventId);
foreach (DataRow row in dt.Rows)
{
StartDate = row["StartDate"].ToString();
EndDate = row["EndDate"].ToString();
StartTime = row["StartTime"].ToString();
EndTime = row["EndTime"].ToString();
EventDescription = row["EventDescription"].ToString();
EventType = row["EventType"].ToString();
if (StartDate.Equals(""))
{
MessageBox.Show("EventId Does Not Exists");
maintainTxtStartDate.Text = "";
maintainTxtStartTime.Text = "";
maintainTxtEndDate.Text = "";
maintainTxtEndTime.Text = "";
MaintainDropDown.Disabled = true;
}
else
{
maintainTxtStartDate.Text = StartDate;
maintainTxtStartTime.Text = StartTime;
maintainTxtEndDate.Text = EndDate;
maintainTxtEndTime.Text = EndTime;
MaintainDropDown.Value = EventType;
maintainTxtDescription.InnerText = EventDescription;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "txtEventId_TextChanged", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
If I specify AutoPostBack="true" for txtEventId then the popup disappears from the screen after I input the value and hit enter. If I set the AutoPostBack = "false" then it is not populating the values as the control is not going to txtEventId_TextChanged function. I do not want to set AutoPostBack="true" because during postback the whole page will reload and the modal popup will disappear. I tried setting scriptmanager and updatepanel for it but since I have already an another existing scriptmanager and updatepanel added in the Default.aspx page, I'm not able to add a new one to it.
Please let me know what I'm doing wrong and how to rectify this. Your guidance is highly appreciated.
You have two options:
RegisterStartupScript
Use the RegisterStartupScript at the end of your method to send JS code to the client, you will send the call to your modal like this
ScriptManager.RegisterStartupScript(this, typeof(Page), "callModal",
"$('#maintenanceModal').modal();", true);
This is the easiest way to accomplish what you want
PageMethods
You can use the PageMethods to return a JSON with the values you want to display, this way you don't need to do a Postback, and you will get the info you want. See the requirements and how to use PageMethods

CQ5 parsys leaves some space even in preview mode?

In edit mode we can see all parsys right, and In preview mode CQ shows us how the page would look in Publish instance. I have a page in which I have hardcoded my textfields and I have used parsys for entering Text (Labels ) on the page ...
But when I enter the preview mode the parsys leaves some space which makes my UI look bad.
Please see the images below.
How do I remove this extra space ?
I think I'm close to solving it ... I think a class in bootstrap CSS is adding the space its not the Parsys anyways here is the code
<%--
Videojet Add New User Component
--%>
<%#include file="/libs/foundation/global.jsp"%>
<%# page
import="com.videojet.hiresite.beans.HRRepresentative,
java.util.*"%>
<%
List<HRRepresentative> hrList = (List<HRRepresentative>)request.getAttribute("hrList");
%>
<cq:include script="head.jsp" />
<html>
<head>
<cq:includeClientLib css="videojetlib" />
<cq:includeClientLib css="customcarousel" />
<cq:includeClientLib css="bootstrapold" />
<link rel="shortcut icon" type="image/ico"
href="/content/dam/videojet/favicon.ico" />
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="brand" href="#"><img
src="/content/dam/videojet/Videojet-Logo.png"></img></a>
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">
<a href="/services/videojet/v1/LoginController/logout"
class="navbar-link">Logout</a>
</p>
<ul class="nav">
<li class="active"><a
href="/services/videojet/v1/AddNewUserController/view">Add
New User</a></li>
<li><a
href="/services/videojet/v1/EditDeleteUsersController/view">Edit
/ Delete User</a></li>
<li><a
href="/services/videojet/v1/EditMyInformationController/view">Edit
My Information</a></li>
<li>Upload Documents</li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
<!-- Adding above new Top navigation -->
<div style =" padding-bottom: 20px;">
<div class="container shadow">
<div class="span11">
<cq:include path="carouselparsys"
resourceType="foundation/components/parsys" />
</div>
<div class="row span11">
<form class="form-horizontal"
action="/services/videojet/v1/AddNewUserController/addUser"
method="POST" enctype="multipart/form-data" id ="addNewUserForm">
<input type="hidden" name="flagField" id="flagField" value="0"/>
<div class="row span11">
<div class="control-group">
<label class="control-label" for="inputEmail"><cq:include path="zensarParsys" resourceType="foundation/components/parsys"/></label>
<div class="controls">
<input type="text" id="addNewUserUID" name="addNewUserUID"
class="input-xlarge" style="height: 30px;">
</div>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">First Name</label>
<div class="controls">
<input type="text" id="addNewUserFirstName"
name="addNewUserFirstName" class="input-xlarge"
style="height: 30px;">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Last Name</label>
<div class="controls">
<input type="text" id="addNewUserLastName"
name="addNewUserLastName" class="input-xlarge"
style="height: 30px;">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Email
Address</label>
<div class="controls">
<input type="text" id="addNewUserEmailId"
name="addNewUserEmailId" class="input-xlarge"
style="height: 30px;">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">HR
Representative</label>
<div class="controls">
<select class="input-xlarge" id="addNewUserHRRep"
name="addNewUserHRRep">
<c:forEach items="${hrList}" var="hr">
<option value="${hr.repId}">${hr.firstName}
${hr.lastName}</option>
</c:forEach>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Non-Compete
Letter</label>
<div class="controls">
<input type="file" id="addNewUserNonCompeteLetter"
name="addNewUserNonCompeteLetter" style="height: 30px;">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Offer
Letter</label>
<div class="controls">
<input type="file" id="addNewUserOfferLetter"
name="addNewUserOfferLetter" style="height: 30px;">
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Employee
Type</label>
<div class="controls">
<label class="checkbox inline"> <input type="radio"
id="addNewUserLocal" name="addNewUserType" checked="checked" value="1">
Local
</label> <label class="checkbox inline"> <input type="radio"
id="addNewUserField" name="addNewUserType" value="2">
Field
</label> <label class="checkbox inline"> <input type="radio"
id="addNewUserInternational" name="addNewUserType" value="3">
International
</label>
<label class="checkbox inline"> <input type="radio"
id="addNewUserInternational" name="addNewUserType" value="4">
Admin
</label>
</div>
<!-- the Div that brings them in line !!! -->
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Special
Intructions</label>
<div class="controls">
<textarea rows="3" class="input-xlarge" id="addNewUserTextArea"
name="addNewUserTextArea"></textarea>
</div>
</div>
<div class="control-group">
<div class="control-label">
<button type="submit" class="btn btn-primary">Add User</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div id="footer">
<cq:include path="addNewUserVideojetFooter"
resourceType="foundation/components/parsys" />
</div>
<cq:includeClientLib js="videojetlib" />
<cq:includeClientLib js="customcarousel" />
<cq:includeClientLib js="bootstrapold" />
<!-- modal -->
<div id="usderIdCheckModal" class="modal hide fade" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
data-backdrop="static">
<div class="modal-header">
<h3 id="myModalLabel">Checking if User Id is available</h3>
</div>
<div class="modal-body" align="center">
<div align="center">
<img src="/content/dam/videojet/ajax-loader.gif"></img>
</div>
<p>Please Wait...</p>
</div>
</div>
<!-- Second Modal -->
<!-- modal -->
<div id="notAvailableModal" class="modal hide fade" tabindex="-1"
role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h3 id="myModalLabel">Warning</h3>
</div>
<div class="modal-body" align="center">
<div align="center">
</div>
<p>This User Id already exists</p>
</div>
</div>
<script src="/etc/designs/videojet/clientlibs/js/addNewUserScript.js"></script>
</body>
</html>
Maybe there is a style rule in the drag components like visible: hidden; change to display: none
Well I solved it my self. The problem was with bootstrap. The extra space was added by bootstrap class="control-group", I just replaced it with class="row".
There is still little space but at least better than before.
You should be able to add ?wcmmode=disabled to the end of your browser address bar to remove extra spacing.

Resources