fullcalendar qtip2 eventClick (for edit) - fullcalendar

I was able to create a qtip2 on dayClick (fullcalendar) and it saves data for that event. Now I am trying to click on the event to have qtip2 load up again, but nothing happens. I have set editable to false (otherwise eventClick would never work).
I would like to be able to re-open a qtip2 event so it can be edited....thanks in advance
(NOTE: the DayClick qtip2 works great)
$('#calendar').fullCalendar({
// put your options and callbacks here
aspectRatio: 1.3,
editable: false,
draggable: true,
selectable: true,
selectHelper: true,
unselectAuto: false,
disableResizing:true,
header: {
right: 'today prev,next',
center: 'title',
left: 'agendaDay,agendaWeek,month'
},
events: "json_events.php",
eventClick: function(event, jsEvent, view) {
//alert(event.title);
$(this).qtip({
content: {
title: { text: event.title },
text: "<span class='title'>Start: </span>" + ($.fullCalendar.formatDate(event.start, 'hh:mmtt')) + "<br><span class='title'>Description: </span>" + event.description + "<br /><input type='button' value='Update' class='button' />"
},
position: {
at: 'top center',
// Position the tooltip above the link
my: 'bottom center',
adjust: {
y: -2,
resize: false // We'll handle it manually
},
viewport: calendar,
container: calendar
},
show: {
solo: true
},
style: {
width: 200,
padding: 5,
color: 'black',
textAlign: 'left',
border: {
width: 1,
radius: 3
},
tip: 'bottom-middle',
classes: 'daytooltip ui-tooltip-dark ui-tooltip-shadow',
tip: {
width: 20, height: 8
}
}
}); //element.qtip
},
dayClick: function(date, allDay, jsEvent, view) {
var month=new Array();
month[0]="January";
month[1]="February";
month[2]="March";
month[3]="April";
month[4]="May";
month[5]="June";
month[6]="July";
month[7]="August";
month[8]="September";
month[9]="October";
month[10]="November";
month[11]="December";
var monthNum=new Array();
monthNum[0]="01";
monthNum[1]="02";
monthNum[2]="03";
monthNum[3]="04";
monthNum[4]="05";
monthNum[5]="06";
monthNum[6]="07";
monthNum[7]="08";
monthNum[8]="09";
monthNum[9]="10";
monthNum[10]="11";
monthNum[11]="12";
var allday = "<label for='allday'><input type='checkbox' id='allday' onClick='enabledisable(this.checked)' /><span>All Day Event</span></label>"
var thisDay = month[date.getMonth()] + '/' + date.getDate() + '/' + date.getFullYear();
var thisDayDBFormat = date.getFullYear() + '-' + monthNum[date.getMonth()] + '-' + date.getDate();
var sHours = "<select id='startTimeHour' name='startTimeHour' class='dropdown-menu-time-qtip' >" +
"<option value='01'>01</option>" +
"<option value='02'>02</option>" +
"<option value='03'>03</option>" +
"<option value='04'>04</option>" +
"<option value='05'>05</option>" +
"<option value='06' selected>06</option>" +
"<option value='07'>07</option>" +
"<option value='08'>08</option>" +
"<option value='09'>09</option>" +
"<option value='10'>10</option>" +
"<option value='11'>11</option>" +
"<option value='12'>12</option>" +
"</select>";
var sMins = "<select id='startTimeMin' name='startTimeMin' class='dropdown-menu-time-qtip' >" +
"<option value='00' selected>00</option>" +
"<option value='15'>15</option>" +
"<option value='30'>30</option>" +
"<option value='45'>45</option>" +
"</select>";
var sAM_PM = "<select id='startTimeAMPM' name='startTimeAMPM' class='dropdown-menu-time-qtip' >" +
"<option value='AM'>AM</option>" +
"<option value='PM' selected>PM</option>" +
"</select>";
var eHours = "<select id='endTimeHour' name='endTimeHour' class='dropdown-menu-time-qtip' >" +
"<option value='01'>01</option>" +
"<option value='02'>02</option>" +
"<option value='03'>03</option>" +
"<option value='04'>04</option>" +
"<option value='05'>05</option>" +
"<option value='06'>06</option>" +
"<option value='07' selected>07</option>" +
"<option value='08'>08</option>" +
"<option value='09'>09</option>" +
"<option value='10'>10</option>" +
"<option value='11'>11</option>" +
"<option value='12'>12</option>" +
"</select>";
var eMins = "<select id='endTimeMin' name='endTimeMin' class='dropdown-menu-time-qtip' >" +
"<option value='00' selected>00</option>" +
"<option value='15'>15</option>" +
"<option value='30'>30</option>" +
"<option value='45'>45</option>" +
"</select>";
var eAM_PM = "<select id='endTimeAMPM' name='endTimeAMPM' class='dropdown-menu-time-qtip' >" +
"<option value='AM'>AM</option>" +
"<option value='PM' selected>PM</option>" +
"</select>";
$(this).qtip({
overwrite: true,
content: {
title: {
text: 'Create Event / Add Menu Item: ', // + month[date.getMonth()] + '/' + date.getDate() + '/' + date.getFullYear(),
button: true
},
//text: $('#fxx').html() // this html was on the form
//text: "<span id='event-create' ><ul><li><input type='checkbox' />All Day</li><li><input type='radio' />input:radio</li><li><select><option>Select</option><option>Foo</option><option>Bar</option></select></li><li></li><li><input type='text' value=" + month[date.getMonth()] + '/' + date.getDate() + '/' + date.getFullYear() + "/></li><li><textarea>textarea</textarea></li></ul><input type='button' class='button' value='Create Event' /></span>"
text: "<div id='event-create'>" +
"<fieldset>" +
"Create a Generic Event OR add a Menu (meal) Event from your Personal Menu!" +
"<br />" +
"<label>When:</label><span>" + thisDay + "</span>" +
"<br />" +
"<form action='.' method='post' name='create_event'>" +
"<input type='hidden' name='action' value='save_event' />" +
"<input type='hidden' name='eventDate' value='" + thisDayDBFormat + "' />" +
"<label for='eventName'>Name:</label><input type='text' name='eventName' value='' title='Letters, numbers, and underscore!' size='30' />" +
"<br />" +
"<label for='eventLocation'>Location:</label><input type='text' name='eventLocation' value='' title='Letters, numbers, and underscore!' size='30' />" +
"<div id='event-create-time'>" +
"<input type='checkbox' name='eventAllDay' onClick='enabledisable(this.checked)' /><span> All Day Event</span><br />" +
"Start: " + sHours + " " + sMins + " " + sAM_PM + "<br />" +
"End: " + eHours + " " + eMins + " " + eAM_PM +
"</div>" +
"<br />" +
"<input type='submit' id='event-button' name='btnSaveGenericEvent' class='button150' value='Create Generic Event' />" +
"<input type='submit' id='event-button' name='btnSaveMenuEvent' class='button150' value='Create Menu Event' />" +
"</form>" +
"</fieldset>" +
"</div>"
//"<a href='#' onclick=" + '"' + "document['my_personal_menu'].submit()" + '"' + " >My Personal Menu >></a>" +
},
position: {
at: 'top center',
// Position the tooltip above the link
my: 'bottom center',
adjust: {
y: -2,
resize: false // We'll handle it manually
},
viewport: calendar,
container: calendar
},
// NOTE: originally, tooltip opened as modal (gray background) and had to close with 'x' button
// Settings were "show: Modal: on: true AND hide: 'false'
//
// To have tooltip popup on each day click AND have any previous tooltip go away (like google calendar)
// Settings "show: modal: on: false AND hide: 'true'"
show: {
ready: true,
event: false,
modal: {
// 'true' = Make it modal (darken the rest of the page)...
on: false,
blur: false // ... but don't close the tooltip when clicked
}
},
// 'false' = does not hide when clicking outside
// 'unfocus' = will hide when clicking outside tooltip IF modal 'on: false' (above)
hide: 'unfocus',
style: {
classes: 'daytooltip ui-tooltip-dark ui-tooltip-shadow ui-tooltip-default width400',
tip: { width: 20, height: 8 }
}
})
.qtip('show');
}

I had the same problem and found a solution from Craig:
Try attaching a qTip with overwrite set to false, and update its content at the end of the call:
$('#calendar').fullCalendar({
eventClick: function(calEvent, jsEvent, view) {
$(this).qTip({
overwrite: false,
content: 'Loading...',
show: { ready: true }
})
.qtip('option', 'content.text', newContent);
}
});

Related

Url.Action to Html.Raw

I have this code om my View. And this is work good.
... onclick="location.href = '#Url.Action("Plan", "Care", new {Area = "HomeC"})'"><img src="~/Content/images/dash/Care.PNG"
How Can I do the same code with Html.Raw?
I tried this
grid.Column(columnName: "Name", header: "", format: #<text>#(item.ListStatus == 1 ? Html.Raw("<button class='btn btn-default btn-plan' title='Care' onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''>" +
"<img src='/Content/images/dash/Care.PNG' class='img-plan' data-interlocutorid=" + item.UserId + " " + "data-interlocutorname=" + item.Name + " " + ">" +
"</button>") : Html.Raw(""))
</text>),
With image all good, but link doesn't work.
Change the single-quotes around your Url.Action(...) to double-quotes instead.
That is, change this portion:
onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''
to this:
onclick='location.href = " + "\"" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "\"'
This will change the rendered output from:
onclick='location.href = '/Care/Plan?Area=HomeC''
to:
onclick='location.href = "/Care/Plan?Area=HomeC"'
onclick=" + "location.href=" + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "'" + ">"
This is work good.

while printing calendar in google chrome, border are not showing up

When I try to print the fullCalendar in google chrome its border are not showing up.
I've placed the #media print query to set border color and width. below is my code for media query.
#media print {
#briefingCalendar { width: 9in; margin-left:0px !important;}
.fc-widget-header, .fc-widget-content{ border: 1px solid #ccc !important;}
}
attached is the snapshot of my calendar without borders.
Below is the code of print view for my fullCalendar.
<?php
$baseUrl = Yii::app()->baseUrl;
$cs = Yii::app()->getClientScript();
$cs->registerCssFile($baseUrl . '/css/jquery-ui-multiselect/jquery.multiselect.css', 'screen, projection');
$cs->registerCssFile($baseUrl . '/css/jquery-ui-multiselect/jquery.multiselect.filter.css', 'screen, projection');
$cs->registerCssFile($baseUrl . '/css/jquery-ui-multiselect/style.css', 'screen, projection');
$cssCoreUrl = $cs->getCoreScriptUrl();
$cs->registerCssFile($cssCoreUrl . '/jui/css/base/jquery-ui.css');
$cs->registerScriptFile($baseUrl . '/javascript/jquery-ui-multiselect/jquery.multiselect.js');
$cs->registerScriptFile($baseUrl . '/javascript/jquery-ui-multiselect/jquery.multiselect.filter.js');
$cs->registerScriptFile($baseUrl . '/javascript/fullcalendar/fullcalendar.js');
$cs->registerScriptFile($baseUrl . '/javascript/jquery.printelement.js');
$cs->registerCssFile($baseUrl . '/css/fullcalendar/fullcalendar.css');
$cs->registerCssFile($baseUrl . '/css/screen.css', 'print');
$cs->registerScriptFile($baseUrl . '/javascript/week_calendar/date.js');
$cs->registerScriptFile($baseUrl . '/javascript/sticky.js');
$cs->registerCss('calendar-print', '
#media print {
#briefingCalendar { width: 9in; margin-left:0px !important;}
.fc-widget-header, .fc-widget-content{ border: 1px solid #ccc !important;}
}
');
$date = DateTime::createFromFormat('Y-m-d', $_GET['startDate']);
$formatDate = "<h2>".$date->format('F Y')."</h2>";
?>
<div id="loading" style="margin-left: 0px; width: 9in;"></div>
<div id="briefingCalendar" style="margin-left: 0px; width: 9in;"></div>
<script type="text/javascript">
var isCurrentBriefingCenterForTitles = '<?php echo $this->isCurrentBriefingCenterForCustomEventsTitle(Yii::app()->user->currentBriefingCenterId); ?>';
$(document).ready(function () {
$('#briefingCalendar').fullCalendar('destroy').fullCalendar({
loading: function(bool) {
if (bool){
$('#loading').html("<div class='alert'><b> Loading calender data, please wait... </b></div>");
}
else{
$('#loading').hide();
setTimeout(function(){printCalendar();}, 1000);
}
},
year: '<?php echo date('Y', strtotime($startDate)) ?>',
month: '<?php echo date('m', strtotime($startDate)) - 1 ?>',
date: '<?php echo date('d', strtotime($startDate)) ?>',
defaultView: '<?php echo $view ?>',
timeFormat: {
'month': 'h(:mm)t{-h(:mm)t}',
'week': 'hh:mmtt{ - hh:mmtt}',
'day': 'hh:mmtt{ - hh:mmtt}'
},
header: {
right: '',
center: 'title',
left: ''
},
events: {
url: '<?php echo $this->createUrl('events') ?>' + '&type=mini&<?php echo $queryStr ?>',
borderColor: 'black'
},
eventRender: function (event, element) {
element.find('.fc-event-title').html(renderEvent(event));
},
viewDisplay: resizeCalendar,
lazyFetching: false,
disableResizing: false
});
});
$('.fc-header-right').css('vertical-align', 'middle').html($('div#calendarOptions div.options').html());
$('.fc-header-left').append($('div#fullCalendarOptions').html());
function renderEvent(event) {
var data = '';
if (!event.data.cn) {
var resultTime = "";
if (event.data.Time) {
var startFormat = "am";
var endFormat = "am";
var time = event.data.Time.split("-");
var startHours = parseFloat(time[0].substr(0, 3));
var startMinutes = parseFloat(time[0].substr(3, 2));
if (startHours >= 12) {
startHours -= 12;
startFormat = "pm";
}
if (startHours == 0)
startHours = 12;
var endHours = parseFloat(time[1].substr(0, 3));
var endMinutes = parseFloat(time[1].substr(4, 2));
if (endHours >= 12) {
endHours -= 12;
endFormat = "pm";
}
if (endHours == 0)
endHours = 12;
resultTime += startHours;
if (startMinutes != 0) {
if (startMinutes < 10) {
resultTime += ":0" + startMinutes;
}
else
resultTime += ":" + startMinutes;
}
if (startFormat != endFormat)
resultTime += startFormat;
resultTime += "-" + endHours;
if (endMinutes != 0) {
if (endMinutes < 10) {
resultTime += ":0" + endMinutes;
}
else
resultTime += ":" + endMinutes;
}
resultTime += endFormat;
}
if (isCurrentBriefingCenterForTitles) {
data = "<div class='cal-event'>" +
"<div class='head'>" +
"<img src='<?php echo $baseUrl ?>/images/briefing_status/" + event.data.statusIcon + "'>" +
"<span class='title'>" + event.title + "</span>" +
"</div>" +
"<div class='desc'>" +
"<label><i>Type: </i>" + event.data.visitType + "</label>" +
"<label><i>Eng: </i>" + event.data.techSupportEmail + "</label>" +
"<label><i>Loc: </i>" + event.data.briefingLoc + "</label>" +
"</div>" +
"</div>";
} else {
data = "<div class='cal-event'>" +
"<div class='head'>" +
"<img src='<?php echo $baseUrl ?>/images/briefing_status/" + event.data.statusIcon + "'>" +
"<span class='title'>" + event.title + "</span>" +
"</div>" +
"<div class='desc'>";
if (event.data.vesBriefingManager == null) {
data += "<label><i>Req: </i>" + event.data.RQ + "</label>";
}
if (event.data.briefingManager && event.data.briefingManager != '' && event.data.briefingManager.name != '') {
var briefingManager = "";
$.each(event.data.briefingManager, function(index, value ){
briefingManager += (value && value != "") ? value + ", " : "";
});
data += "<label><i><?php echo Yii::app()->settings->get("briefing", "customMgrField"); ?> </i>"
+ briefingManager.replace(/,(\s+)?$/, '')
+ "</label>";
}
if (event.data.vesBriefingManager != null) {
data += "<label><i>VES Mgr: </i>" + event.data.vesBriefingManager + "</label>";
}
data += "<label><i>Loc: </i>" + event.data.briefingLoc + "</label>";
if (event.data.tourTime != null) {
data += "<label><i>Tour Time: </i>" + event.data.tourTime + "</label>";
}
if (event.data.vicBriefingManager != null) {
data += "<label><i>Tour Host: </i>" + event.data.vicBriefingManager + "</label>";
}
data += "</div>" +
"</div>";
}
} else {
data = "<div class='cal-event'>" +
"<div class='head'>" +
"<img src='<?php echo $baseUrl ?>/images/calendar_note/" + event.data.noteType + "'>" +
"<span class='title'>" + event.title + "</span>" +
"</div>" +
"</div>";
}
return data;
}
function resizeCalendar() {
var currentView = $('#briefingCalendar').fullCalendar('getView');
if(currentView.name === 'agendaWeek' || currentView.name === 'agendaDay') {
currentView.setHeight(2000);
$(".fc-header-center").html('');
}else if(currentView.name === 'month'){
$(".fc-header-center").html('<?php echo $formatDate; ?>');
}
}
function printCalendar()
{
$("#briefingCalendar").printElement(
{
overrideElementCSS:[
{ href:'<?php echo $baseUrl . '/css/fullcalendar/fullcalendar.css'; ?>',media:'print'}
],
printMode:'iframe'
});
}
</script>
overrideElementCSS accepts 3 parameters and I was assigning only two parameters.
Below is the proper way to use overrideElementCSS.
$("selector").printElement(
{
overrideElementCSS:[
'thisWillBeTheCSSUsed.css',
{ href:'thisWillBeTheCSSUsedAsWell.css',media:'print'}]
});
Taken from [http://projects.erikzaadi.com/jQueryPlugins/jQuery.printElement/]

Toggle Multiple Image Overlays in Google Maps v3 using Checkboxes

Please give me a piece of advice.
I'm trying to create a map with multiple image overlays. I'd like to show/hide each overlays by checking the checkbox. I used GeoJason's code as a reference, but for some reason, it doesn't work properly for me: whether checked or unchecked, no layer appears. Please tell me what's wrong with my code.
This is script part.
<script>
var server = 'https://gbank.gsj.jp/seamless/tilemap/';
var geolMapType = 'basic';
var layer = 'glfn';
var opacity = 0.7;
var map;
function initialize() {
var mapOptions = {
zoom: 7,
center: new google.maps.LatLng(34.59, 135.67),
mapTypeId: google.maps.MapTypeId.ROADMAP,
minZoom: 5,
maxZoom: 13
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
overlayMaps = [
{ //sedTer
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //sedMar
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=_____AAAAAAAAAAAAAAAAAAAAAAwBAIEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //accSed
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAA______4AAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //accMaf
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAH-AAAAAAAAAAAAAAAgAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //volTep
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //volDeb
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //volInt
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAeAAAAAAAAAAAAAAAehwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //pluFel
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAP_-AAAAAAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //pluMaf
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAABAAAAAAAAAD_-AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //pluMig
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png' + '?select=gAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
},
tileSize: new google.maps.Size(256, 256),
isPng: true
}, { //all
getTileUrl: function (coord, z) {
return server + geolMapType + '/' + layer + '/' + z + '/' + coord.y + '/' + coord.x + '.png';
},
tileSize: new google.maps.Size(256, 256),
isPng: true,
opacity: 0.2
}
];
$('.layer').click(function(){
var layerID = parseInt($(this).attr('id'));
if ($(this).attr('checked')){
var overlayMap = new google.maps.ImageMapType(overlayMaps[layerID]);
map.overlayMapTypes.setAt(layerID, overlayMap);
}
else {
if (map.overlayMapTypes.getLength() > 0){
map.overlayMapTypes.setAt(layerID, null);
}
}
});
for (i = 0; i < overlayMaps.length; i++){
map.overlayMapTypes.push(null);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
And this is HTML code.
<input type="checkbox" id="00" class="layer" name="sedTer" /><label for="00">Sedimentary Rocks, Terrace</label><br />
<input type="checkbox" id="01" class="layer" name="sedMar" /><label for="01">Sedimentary Rocks, Non-marine&Marine</label><br />
<input type="checkbox" id="02" class="layer" name="accSed" /><label for="02">Accretionary Complexes, Mainly sedimentary rocks</label><br />
<input type="checkbox" id="03" class="layer" name="accMaf" /><label for="03">Accretionary Complexes, Mafic</label><br />
<input type="checkbox" id="04" class="layer" name="volTep" /><label for="04">Volcanic Rocks, Tephra</label><br />
<input type="checkbox" id="05" class="layer" name="volDeb" /><label for="05">Volcanic Rocks, Debris</label><br />
<input type="checkbox" id="06" class="layer" name="volInt" /><label for="06">Volcanic Rocks, Intrusive</label><br />
<input type="checkbox" id="07" class="layer" name="pluFel" /><label for="07">Plutonic Rocks, Felsic</label><br />
<input type="checkbox" id="08" class="layer" name="pluMaf" /><label for="08">Plutonic Rocks, Mafic</label><br />
<input type="checkbox" id="09" class="layer" name="pluMig" /><label for="09">Plutonic Rocks, Migmatitic</label><br />
<input type="checkbox" id="10" class="layer" name="all" /><label for="10">All</label><br />
Please, no flames about my bad English. Thank you for your time.
The issue is this:
if ($(this).attr('checked'))
when you click a checkbox, the checked-attribute of a checkbox will not change.
But the checked-property will, use this instead:
if ($(this).prop('checked'))

Submit form fails

I have a page that which is an exam page,it selects all MCQ questions with their answers...
and in server side page load i add div.innerHtml += "html tags " + question + radio buttons containing answers and it keeps selecting from database till all questions are rendered in client side, the thing is i add all these questions and tags in form and in its end there is a input submit button which should submit all radio buttons values but even if i set form action i cant get the radio buttons values...
Here is some code :
using (SqlDataReader sr1 = command1.ExecuteReader())
{
cc.InnerHtml = "<form id=\"form2\" name=\"form2\" method=\"post\" action=\"\">";
while (sr1.Read())
{
i++;
iString = i.ToString();
questionText = sr1["text"].ToString();
question_first_wrong_answer = sr1["first_wrong_answer"].ToString();
question_second_wrong_answer = sr1["second_wrong_answer"].ToString();
question_right_answer = sr1["right_answer"].ToString();
questionValue = (int)sr1["value"];
c = answerPos.Next(0, 10);
cc.InnerHtml += "<span>" + iString + "- " + questionText +"</span>"
+ "<br />"
+ "<table style=\"width:77%; margin-left: 47px;\">"
+ "<tr>"
+ " <td style=\"width: 210px\">"
+ " <input type=\"radio\" name=\"question" + iString + "a\" value=\"" + question_first_wrong_answer + "\" />" + question_first_wrong_answer + "</td>"
+ "<td style=\"width: 210px\">"
+ "<input type=\"radio\" name=\"question" + iString + "a\" value=\"" + question_second_wrong_answer + "\" />" + question_second_wrong_answer + "</td>"
+ "<td style=\"width: 210px\">"
+ "<input type=\"radio\" name=\"question" + iString + "a\" value=\"" + question_right_answer + "\" />" + question_right_answer + "</td>"
+ "</tr>"
+ "</table>"
+ "<br />";
}
sr1.Close();
cc.InnerHtml += "<input id=\"Submit1\" type=\"submit\" value=\"Submit\" />"
+ "</form>";
}
Do not Use InnerHtml. Its Wrong.
Use Inbuild HtmlPage Class
Use Like this for Example
Page.Controls.Add(
new LiteralControl(#"<html>\r\n<body>\r\n
<h1>Welcome to my Homepage!</h1>\r\n"));
HtmlForm Form1 = new HtmlForm();
Form1.ID = "Form1";
Form1.Method = "post";
Form1.Controls.Add(
new LiteralControl("\r\nWhat is your name?\r\n"));
TextBox TextBox1 = new TextBox();
TextBox1.ID = "txtName";
Form1.Controls.Add(TextBox1);
Form1.Controls.Add(
new LiteralControl("\r\n<br />What is your gender?\r\n"));
DropDownList DropDownList1 = new DropDownList();
DropDownList1.ID = "ddlGender";
ListItem ListItem1 = new ListItem();
ListItem1.Selected = true;
ListItem1.Value = "M";
ListItem1.Text = "Male";
DropDownList1.Items.Add(ListItem1);
ListItem ListItem2 = new ListItem();
ListItem2.Value = "F";
ListItem2.Text = "Female";
DropDownList1.Items.Add(ListItem2);
ListItem ListItem3 = new ListItem();
ListItem3.Value = "U";
ListItem3.Text = "Undecided";
DropDownList1.Items.Add(ListItem3);
Form1.Controls.Add(
new LiteralControl("\r\n<br /> \r\n"));
Button Button1 = new Button();
Button1.Text = "Submit!";
Form1.Controls.Add(Button1);
Form1.Controls.Add(
new LiteralControl("\r\n</body>\r\n</html>"));
Controls.Add(Form1);
Remove the server form element (<form runat="server" ). If that is present, this new form is discarded.
Also you are using the same name for different input controls.
name=\"question" + iString + "a\" value=\""
So you need to have unique names for the radio too.

Web forms : sending image into email not displaying in outlook?

I'm sending an image through web form the image is displayed well into gmail ,yahoo etc.
But i'm not able to view that image when I send it on Outlook
what would be wrong please help.
Code:
//Variable mg have a html code with 'cid:uniqueId1’ calls image from function SendMail12
void birthday()
{
Coonection con = new Coonection();
sql = "select es.PORTNO,es.SERVERNAME,es.EMAILID,es.PASSWORD,e.efrom,e.SerNo,e.eto,e.ecc,e.emessage,e.eflag,e.EmpID,e.FIRSTNAME,e.LASTNAME,e.DeptName,e.FromDate,e.Todate,e.Reason from EMAILSETTING es,EmailSender e";
SqlDataAdapter da = new SqlDataAdapter(sql, con.GetConnection());
DataSet ds = new DataSet();
da.Fill(ds);
string sub = "Message";
int portnum, n,sn;
string servername1, passwo, account, t, ecc, mg, flage,mg2;
sql = "select count(srno)from EmailSender";
SqlCommand cmd = new SqlCommand(sql, con.GetConnection());
// dr = cmd.ExecuteReader();
n = Convert.ToInt32(cmd.ExecuteScalar());
//while (i)
//{
for (int i = 0; i < n; i++)
{
if (ds.Tables[0].Rows.Count > 0)
{
portnum = Convert.ToInt32(ds.Tables[0].Rows[0]["PORTNO"].ToString());
servername1 = ds.Tables[0].Rows[0]["SERVERNAME"].ToString(); //Table(0).Rows(0)("SmtpServerName").ToString();
account = ds.Tables[0].Rows[0]["EMAILID"].ToString();
passwo = ds.Tables[0].Rows[0]["PASSWORD"].ToString();
t = ds.Tables[0].Rows[i]["eto"].ToString();
ecc = ds.Tables[0].Rows[i]["ecc"].ToString();
mg2 = ds.Tables[0].Rows[i]["emessage"].ToString();
flage = ds.Tables[0].Rows[i]["eflag"].ToString();
sn = Convert.ToInt32(ds.Tables[0].Rows[i]["SerNo"].ToString());
if (flage == "N" && mg2 == "Wish You a Very Happy Returns of the Day.<P> From - Daccess Security Systems Pvt ")
{
mg = " <html> " +
"<body background= 'meet.jpg'>" +
"<head> " +
"<title>Untitled Document</title> " +
"<meta content='text/plain; charset=us-ascii' http-equiv='Content-Type' />" +
"<style type='text/css'> " +
".style1 { " +
"font-family: Arial, Helvetica, sans-serif; " +
"font-weight: bold; " +
"font-size: 18px; " +
"color: #3333CC; " +
"} " +
".style3 { " +
"font-family: 'Times New Roman', Times, serif; " +
"color: #003399; " +
"} " +
".style4 { " +
"font-family: Arial, Helvetica, sans-serif; " +
"font-weight: bold; " +
"font-size: 12px; " +
"} " +
".style11 { " +
"color: #1A588D; " +
"font-family: 'Times New Roman', Times, serif; " +
"font-weight: bold; " +
"} " +
".style15 { " +
"color: #1A588D; " +
"font-weight: bold; " +
"} " +
".style18 {color: #FFFFFF; font-weight: bold; } " +
"body { " +
"margin-top: 1px; " +
"margin-left: 1px; " +
"margin-right: 1px; " +
"margin-bottom: 1px; " +
"} " +
"</style> " +
"<link href='Untitled-1.htm' id='1' title='view'> " +
"<script language='JavaScript' type='text/JavaScript'> " +
"function MM_reloadPage(init) { " +
"if (init==true) with (navigator) {if ((appName=='Netscape')&&(parseInt(appVersion)==4)) { " +
"document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} " +
"else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); " +
"} " +
"MM_reloadPage(true); " +
"</script> " +
"<style type='text/css'> " +
"a:link { " +
"text-decoration: none; " +
"} " +
"a:visited { " +
"text-decoration: none; " +
"} " +
"a:hover { " +
"text-decoration: none; " +
"} " +
"a:active { " +
"text-decoration: none; " +
"} " +
".style20 {font-size: 12px} " +
"</style></head> " +
"<body> " +
"<p class='style1'><img src='cid:uniqueId' width='145' height='111'></p> " +
"<table border= 1 align ='left'>" +
"<tr>" + "<td>Employee ID :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["EmpID"].ToString() + "</td>" +
"</tr>" +
"<tr>" + "<td>Employee Name :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["FIRSTNAME"].ToString() + " " + ds.Tables[0].Rows[i]["LASTNAME"].ToString() + "</td>" +
"</tr>" +
"<tr>" + "<td>Department :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["DeptName"].ToString() + "</td>" +
"</tr>" +
"<tr>" + "<td>Message :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["emessage"].ToString() + "</td>" +
"</tr>" +
"<tr>"+
"<td>"+
"<pre align='left' class='style3'><strong><img src='cid:uniqueId1' width='286' height='177'></strong></pre> " +
"<pre align='left' class='style4'> <a name='t'></a> Please do not reply to this email.</pre>" +
"<p align='left' class='style3'> </p> " +
"</td>"+"</tr>"+"</table>"+
"</body> " +
"</html> ";
if (flage == "N" && mg2 == "Wish You a Very Happy Returns of the Day.<P> From - Daccess Security Systems Pvt ")
{
SendMail12(account, passwo, t, sub, mg, ecc, servername1, portnum);
sql = "Update EmailSender set eflag ='Y' where SerNo = '" + sn.ToString() + "'";
SqlCommand cmd4 = new SqlCommand(sql, con.GetConnection());
cmd4.ExecuteNonQuery();
}
}
}
else
{
servername1 = "";
portnum = 0;
account = "";
passwo = "";
MessageBox.Show("Email Setting Is Not Stored");
}
}
}
// Send mail function
public static bool SendMail12(string gMailAccount, string password, string to, string subject, string message, string cc, string server, int port)
{
try
{
NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(gMailAccount);
msg.To.Add(new MailAddress(to));
string[] s;
s = cc.Split(';');
for (int i = 0; i < s.Length; i++)
{
msg.CC.Add(new MailAddress(s[i].ToString()));
}
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Host = server;
client.Port = port;
client.Timeout = 100000;
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Credentials = loginInfo;
string palinBody = "Plain text content, viewable by those clients that don't support html";
AlternateView plainView = AlternateView.CreateAlternateViewFromString(palinBody, null, "text/plain");
string htmlBody = message;
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, "text/html");
//create the AlternateView for embedded image
AlternateView imageView = new AlternateView("D:\\Aniket Work\\New Folder Update\\EmailSender\\EmailSender\\images\\Daccess-logo.gif", MediaTypeNames.Image.Gif);
imageView.ContentId = "uniqueId";
imageView.TransferEncoding = TransferEncoding.Base64;
AlternateView imageView1 = new AlternateView("D:\\Aniket Work\\New Folder Update\\EmailSender\\EmailSender\\images\\birthday1images.jpg", MediaTypeNames.Image.Jpeg);
imageView1.ContentId = "uniqueId1";
imageView1.TransferEncoding = TransferEncoding.Base64;
//add the views
msg.AlternateViews.Add(plainView);
msg.AlternateViews.Add(htmlView);
msg.AlternateViews.Add(imageView);
msg.AlternateViews.Add(imageView1);
client.Send(msg);
return true;
}
catch (Exception e)
{
return false;
}
}
You should be giving absolute paths to your resources
e.g.
in above code, your body background should be something like
<body background= 'http://yourdomain.com/meet.jpg'>
same thing applies to your image tag or you can have inline content disposition
EDIT
Do you see something like this when you view the mail?

Resources