|
Hey
I have a problem regarding showing my webpage in firefox. As far as Internet Explorer is concerned, the calender in javascript is working fine but the same program when i run in firefox, the calender is not popping out. Why is that and how to solve it ?
Thanks
Suchita
suchita
|
|
|
|
|
What calendar are you using? What button? Without some context how do you expect anyone to answer you?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ok. Here is the javascript code:
function positionInfo(object) {
var p_elm = object;
this.getElementLeft = getElementLeft;
function getElementLeft() {
var x = 0;
var elm;
if(typeof(p_elm) == "object"){
elm = p_elm;
} else {
elm = document.getElementById(p_elm);
}
while (elm != null) {
x+= elm.offsetLeft;
elm = elm.offsetParent;
}
return parseInt(x);
}
this.getElementWidth = getElementWidth;
function getElementWidth(){
var elm;
if(typeof(p_elm) == "object"){
elm = p_elm;
} else {
elm = document.getElementById(p_elm);
}
return parseInt(elm.offsetWidth);
}
this.getElementRight = getElementRight;
function getElementRight(){
return getElementLeft(p_elm) + getElementWidth(p_elm);
}
this.getElementTop = getElementTop;
function getElementTop() {
var y = 0;
var elm;
if(typeof(p_elm) == "object"){
elm = p_elm;
} else {
elm = document.getElementById(p_elm);
}
while (elm != null) {
y+= elm.offsetTop;
elm = elm.offsetParent;
}
return parseInt(y);
}
this.getElementHeight = getElementHeight;
function getElementHeight(){
var elm;
if(typeof(p_elm) == "object"){
elm = p_elm;
} else {
elm = document.getElementById(p_elm);
}
return parseInt(elm.offsetHeight);
}
this.getElementBottom = getElementBottom;
function getElementBottom(){
return getElementTop(p_elm) + getElementHeight(p_elm);
}
}
function CalendarControl() {
var calendarId = 'CalendarControl';
var currentYear = 0;
var currentMonth = 0;
var currentDay = 0;
var selectedYear = 0;
var selectedMonth = 0;
var selectedDay = 0;
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var dateField = null;
function getProperty(p_property){
var p_elm = calendarId;
var elm = null;
if(typeof(p_elm) == "object"){
elm = p_elm;
} else {
elm = document.getElementById(p_elm);
}
if (elm != null){
if(elm.style){
elm = elm.style;
if(elm[p_property]){
return elm[p_property];
} else {
return null;
}
} else {
return null;
}
}
}
function setElementProperty(p_property, p_value, p_elmId){
var p_elm = p_elmId;
var elm = null;
if(typeof(p_elm) == "object"){
elm = p_elm;
} else {
elm = document.getElementById(p_elm);
}
if((elm != null) && (elm.style != null)){
elm = elm.style;
elm[ p_property ] = p_value;
}
}
function setProperty(p_property, p_value) {
setElementProperty(p_property, p_value, calendarId);
}
function getDaysInMonth(year, month) {
return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
}
function getDayOfWeek(year, month, day) {
var date = new Date(year,month-1,day)
return date.getDay();
}
this.setDate = setDate;
function setDate(year, month, day) {
if (dateField) {
if (month < 10) {month = "0" + month;}
if (day < 10) {day = "0" + day;}
var dateString = month+"-"+day+"-"+year;
dateField.value = dateString;
hide();
}
return;
}
this.changeMonth = changeMonth;
function changeMonth(change) {
currentMonth += change;
currentDay = 0;
if(currentMonth > 12) {
currentMonth = 1;
currentYear++;
} else if(currentMonth < 1) {
currentMonth = 12;
currentYear--;
}
calendar = document.getElementById(calendarId);
calendar.innerHTML = calendarDrawTable();
}
this.changeYear = changeYear;
function changeYear(change) {
currentYear += change;
currentDay = 0;
calendar = document.getElementById(calendarId);
calendar.innerHTML = calendarDrawTable();
}
function getCurrentYear() {
var year = new Date().getYear();
if(year < 1900) year += 1900;
return year;
}
function getCurrentMonth() {
return new Date().getMonth() + 1;
}
function getCurrentDay() {
return new Date().getDate();
}
function calendarDrawTable() {
var dayOfMonth = 1;
var validDay = 0;
var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
var daysInMonth = getDaysInMonth(currentYear, currentMonth);
var css_class = null; //CSS class for each day
var table = "<table cellspacing='0' cellpadding='0' border='0'>";
table = table + "<tr class='header'>";
table = table + " <td colspan='2' class='previous'><a href='javascript:changeCalendarControlMonth(-1);'><</a> <a href='javascript:changeCalendarControlYear(-1);'>«</a></td>";
table = table + " <td colspan='3' class='title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
table = table + " <td colspan='2' class='next'><a href='javascript:changeCalendarControlYear(1);'>»</a> <a href='javascript:changeCalendarControlMonth(1);'>></a></td>";
table = table + "</tr>";
table = table + "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";
for(var week=0; week < 6; week++) {
table = table + "<tr>";
for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
if(week == 0 && startDayOfWeek == dayOfWeek) {
validDay = 1;
} else if (validDay == 1 && dayOfMonth > daysInMonth) {
validDay = 0;
}
if(validDay) {
if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
css_class = 'current';
} else if (dayOfWeek == 0 || dayOfWeek == 6) {
css_class = 'weekend';
} else {
css_class = 'weekday';
}
table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
dayOfMonth++;
} else {
table = table + "<td class='empty'> </td>";
}
}
table = table + "</tr>";
}
table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
table = table + "</table>";
return table;
}
this.show = show;
function show(field) {
// If the calendar is visible and associated with
// this field do not do anything.
if (dateField == field) {
return;
} else {
dateField = field;
}
if(dateField) {
try {
var dateString = new String(dateField.value);
var dateParts = dateString.split("-");
selectedMonth = parseInt(dateParts[0],10);
selectedDay = parseInt(dateParts[1],10);
selectedYear = parseInt(dateParts[2],10);
} catch(e) {}
}
if (!(selectedYear && selectedMonth && selectedDay)) {
selectedMonth = getCurrentMonth();
selectedDay = getCurrentDay();
selectedYear = getCurrentYear();
}
currentMonth = selectedMonth;
currentDay = selectedDay;
currentYear = selectedYear;
if(document.getElementById){
calendar = document.getElementById(calendarId);
calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);
setElementProperty('display', 'block', 'CalendarControlIFrame');
setProperty('display', 'block');
var fieldPos = new positionInfo(dateField);
var calendarPos = new positionInfo(calendarId);
var x = fieldPos.getElementLeft();
var y = fieldPos.getElementBottom();
x=x+155;
y=y-22;
setProperty('left', x + "px");
setProperty('top', y + "px");
setElementProperty('left', x + "px", 'CalendarControlIFrame');
setElementProperty('top', y + "px", 'CalendarControlIFrame');
setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
}
}
this.hide = hide;
function hide() {
if(dateField) {
setProperty('display', 'none');
setElementProperty('display', 'none', 'CalendarControlIFrame');
dateField = null;
}
}
}
var calendarControl = new CalendarControl();
function showCalendarControl(textField) {
calendarControl.show(textField);
}
function hideCalendarControl() {
calendarControl.hide();
}
function setCalendarControlDate(year, month, day) {
calendarControl.setDate(year, month, day);
}
function changeCalendarControlYear(change) {
calendarControl.changeYear(change);
}
function changeCalendarControlMonth(change) {
calendarControl.changeMonth(change);
}
document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>");
document.write("<div id='CalendarControl'></div>");
suchita
|
|
|
|
|
One, format your code properly using the pre tags. See the words code block above the textarea you used to add this mess?
Two, I didn't say, "dump everything you are using here"
Three, why reinvent to wheel. http://jqueryui.com/demos/datepicker/[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
even this third one, I couldn't use in .net..
suchita
|
|
|
|
|
SayamiSuchi wrote: I couldn't use in .net..
Of course you can. It's JavaScript, it has nothing to do with .net
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Ya but it is not working while i try to use it. Thats what my problem was. The code which is working fine in IE is not working in firefox.
suchita
|
|
|
|
|
JQuery is compatible with IE 6+, FF 2+, Chrome, Opera 9+, Safari 3+.
So what browser and what version are you using that it doesn't work?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
At times Javascript code are little different for IE & FF... might be the way a certain element is used in order to display calendar is not working properly in your FF.
Just debug the javascript code and handle it based on the browser.
|
|
|
|
|
But it is working fine in IE. How do i know which part is to debug??
suchita
modified on Wednesday, May 12, 2010 3:13 PM
|
|
|
|
|
Hmmmm .... let's see now .... it isn't working in Firefox. Let me think. Hmmm.
OK, just a wild guess, but ... maybe you should debug it in Firefox?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
What do you mean by which part? The Javascript code that triggers showing of the Calendar!
there must be a click event that triggers to show the calendar, right? That part. Use firefox as browser while debugging. Hope you know how to debug Javascripts!
|
|
|
|
|
Hi,
Can any body tell me how to use checkboxlist in ASP.NET MVC 2.0
Thanks for help
|
|
|
|
|
An ASP.NET CheckBoxList is rendered as a table an input element and label in the cells so if you want to replicate it
<table>
<% foreach(item in ViewData["MyList"]) { %>
<tr><td> <% Html.CheckBox(...) %> <% Html.Label(...) %> </td></tr>
<% } %>
</table>
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I have a form with a data bound accordion on it. It's being data bound the standard way:
Accordion1.DataSource = dt.DefaultView;
Accordion1.DataBind();
...
The entire form works perfectly at this stage. There is a major problem when I add a row to the datatable and rebind it.
DataRow newDr = dt.NewRow();
...
dt.Rows.Add(newDr);
Accordion1.DataSource = dt.DefaultView;
Accordion1.DataBind();
At this point, the accordion rebinds, and it displays correctly on the page. But there is a problem. When I do any action on the page, the code behind doesn't see the new row. In fact, all the values from the accordion are null or string.Empty. I then checked view source on the browser, and it doesn't show anything for the new row. It seems like it doesn't exist, but it is there on the screen.
As usual, I am under an extreme deadline, and ANY suggestions would be greatly appreciated. I'm sure it's something very stupid that I am missing.
Thanks
|
|
|
|
|
just add proper data to the newly added row.
Like,
newDr["name"]="Jinal Desai"
Then might be your problem solved.
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Thanks for your reply, but I am doing that. In my original message, I replaced the assignment portion of the code with "..." to save space and to not take away from the real issue, which is that the control does not maintain state across postbacks when the datasource has been changed.
I put a ticket into Microsoft, and they confirmed my findings. The problem is that they created the controls and put them out to open source, so they will not fix the problem.
|
|
|
|
|
I have an asp image control. And I have done the image zooming dynamically using javascript.
It worked perfecltly. But for very high resolution images image will flicker while zooming(in IE only in all other broswers there is no image flicker).
Locally there is a slight flickering only but after publishing my aapln there is high image flickering(IE).
How to avoid these image flicking in IE?
Pls help
Thanks in advance
|
|
|
|
|
Hi People,
I have a problem with AJAX enabled Listbox. The thing is, my listbox is generated dynamically at runtime. After selecting few items in it, if I do anything which cause partial postback (like clicking a button), the listbox index is reset to 0.
This is obvious because on each partial postback, the listbox is regenarating again.
I have done the coding for reseting the selected fields but it is not scrolling to the selected items automatically. User then has to scroll down manually to see if anything is selected.
Is there anyway I can scroll up/down into javascript for Listboxes. ScrollTo property only works for "window" element not "select".....
Thanks for any help.
Regards,
Anand Desai
|
|
|
|
|
AnandDesai19 wrote: ScrollTo property only works for "window" element not "select".....
It works with div's and grid too. I have done that in my project. Try setting the scroll's in the Ajax End request handler using javascript. It should work.
|
|
|
|
|
Hi,
I am using ajax for my existing VS 2005 Web application.
I have applied all the necessary modification to Web.config.
My application is working fine when we opening the page.
We are also providing Back and Forward links to user ( similar to browser Back and Forward for history) .
When user visits 2nd page, we are saving the generated HTML of first page into a java script variable .like below.
var html = document.frames[“MyFrame”].document.documentElement.outerHTML;
when user clicks on Back link we displaying the page from stored java script variable. Like below
var doc = document.frames[“MyFrame”].document.open();
doc.write(html);
Here we are getting error saying “Microsoft JScript runtime error: 'Sys' is undefined”.
Sys.WebForms.PageRequestManager._initialize('ctl00', document.getElementById('Form1'));
Thanks,
Salmon
|
|
|
|
|
salmonraju wrote: we are saving the generated HTML of first page into a java script variable
I'm sorry but this is horrendously stupid idea. This falls under the just because you can doesn't me you should rule.
Just navigate back to the page in question and let the rendering engine do what it is meant to. There are plenty of examples of using the back an forward buttons with Ajax
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Create AJAX enabled website to resolve this issue.
|
|
|
|
|
hi
i am using following code to export gridview to excel..but the generated excel file does not contain rows and columns as normal excel file ...
can any on e suggest a solution for that
here is my code
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
String savefile = heading;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + savefile + ".xls");
HttpContext.Current.Response.Charset = "";
gv.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
|
|
|
|
|
use the below code in you ExporttoExcel function
using conn as new SqlConnection(Constring)
conn.open()
da=new sqlDataAdapter(query,conn)
da.fill(ds)
End Using
Dim Gridview1 as New Gridview
Gridview1.datasource=ds
Gridview1.databind()
Response.clear()
Response.Buffer=true
Response.AddHeader("content-disposition","attachment;filename=testfile.xls")
Response.charset=""
Response.ContentType="application/vdn.ms-excel"
Dim sw as new StringWriter()
Dim hw as new HtmlTextWriter(sw)
For i as integer=0 To Gridview1.Rows.Count-1
Gridview1.Row(i).Attribute.Add("class","textmode")
Next
Gridview1.RenderControl(hw)
dim style as String="<style> .textmode(mso-number-format:\@;}</style>"
Response.write(style)
Response.output.write(sw.ToString())
Response.Flush()
Response.End()
Imtiaz A.K
|
|
|
|
|