|
Three dropdowns:
<asp:dropdownlist id="lstDay" Runat="server"></asp:dropdownlist>-
<asp:dropdownlist id="lstMonth" Runat="server">
<asp:ListItem Value="Jan">Jan</asp:ListItem>
<asp:ListItem value="Feb">Feb</asp:ListItem>
<asp:ListItem value="Mar">Mar</asp:ListItem>
<asp:ListItem value="Apr">Apr</asp:ListItem>
<asp:ListItem value="May">May</asp:ListItem>
<asp:ListItem value="Jun">Jun</asp:ListItem>
<asp:ListItem value="Jul">Jul</asp:ListItem>
<asp:ListItem value="Aug">Aug</asp:ListItem>
<asp:ListItem value="Sep">Sep</asp:ListItem>
<asp:ListItem value="Oct">Oct</asp:ListItem>
<asp:ListItem value="Nov">Nov</asp:ListItem>
<asp:ListItem value="Dec">Dec</asp:ListItem>
</asp:dropdownlist>-
<asp:dropdownlist id="lstYear" Runat="server"></asp:dropdownlist>
some javascript funcitons:
function daysInMonth(x,ty) {
if (x==3 || x==5 || x==8 || x==10) {
return 30;
} else if (x==1) {
if ((ty % 4 == 0) && !(ty % 100 == 0)) {
return 29;
} else {
return 28;
}
} else {
return 31;
}
}
function setday() {
var list1 = document.getElementById("lstYear");
var list2 = document.getElementById("lstMonth");
var list3 = document.getElementById("lstDay");
var yy = list1.selectedIndex + 2000;
var cd = list3.selectedIndex + 1; // because selectedIndex is from 0 to (up to) 30
var NumberOfDays;
var n;
NumberOfDays = daysInMonth(list2.selectedIndex, yy);
list3.options.length=0;
for (n=0;n<NumberOfDays;n++) {
list3.options[n] = new Option((n+1).toString(),(n+1).toString());
}
if (cd > NumberOfDays || cd == 0) {
list3.options[dt-1].selected = true;
} else {
list3.options[cd-1].selected = true;
}
}
function leapYear() {
var list2 = document.getElementById("lstMonth");
if (list2.selectedIndex == 1) {setday();}
}
and some code-behind to intialise the boxes (call in Page_load under an If Not Page.IsPostback then...:
(NB this example initialises them to "yesterday" - set yd = Now for "today")
Private Sub InitDropdowns()
Dim y As Integer, li As ListItem
Dim yd As Date = DateAdd(DateInterval.Day, -1, Now)
For y = 2000 To Year(Now)
li = New ListItem
li.Value = y.ToString
li.Text = y.ToString
lstYear.Items.Add(li)
li = Nothing
Next
For y = 1 To DaysInMonth(Month(yd), Year(yd))
li = New ListItem
li.Value = y.ToString
li.Text = y.ToString
lstDay.Items.Add(li)
li = Nothing
Next
lstDay.SelectedValue = Day(yd)
lstMonth.SelectedValue = Microsoft.VisualBasic.MonthName(Month(yd), True)
lstYear.SelectedValue = Year(yd)
lstMonth.Attributes.Add("onchange", "setday()")
lstYear.Attributes.Add("onchange", "leapYear()")
End Sub
Private Function DaysInMonth(ByVal x As Integer, ByVal ty As Integer) As Integer
Select Case x
Case 2
If (ty Mod 4 = 0) And (ty Mod 100 = 0) Then
Return 29
Else
Return 28
End If
Case 4, 6, 9, 11
Return 30
Case Else
Return 31
End Select
End Function
You can then read the selected date on postback with:
Dim d As Date = CDate(lstDay.SelectedValue & "-" & lstMonth.SelectedValue & "-" & lstYear.SelectedValue)
works a treat - good luck!
Fred
|
|
|
|
|
That's great! Thanks a lot for your reply, and help!
|
|
|
|
|
OKay, I have scoured the net, google, msdn and various other places trying to find an answer to this. I have VS2003 installed on my Vista Ultimate pc, and everything is working fine, EXCEPT the debugger for asp .net projects. I get the following error whenever i try to debug:
Error while trying to run project: Unable to start debugging on the web server. COuld not start ASP .Net or ATL server debugging.
Verify that the ASP .Net or ATL server is correctly installed on the server.
I am running the 1.1 framework, completely patched, as is vs2003. i have installed IIS 7 with all the front page extensions and fun iis6 extras included. i am running vs as an administrator, and even gave the ASP.Net axccount admin rights. I have covered every base i can think of, but am still having zerp luck debugging asp .net applications in vs2003. does anyopne else have any insight/ideas?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Hi experts.
I just started programming in asp.net. Here is one task that I am having problems with.
On a asp.net page there are 2 buttons(edit and save). I want to validate 2 fields only when the save button is clicked. If edit is clicked, then I don’t want to validate any fields. I thought that using javascript I can identify which button was clicked. Something like this:
<script language="javascript" type="text/javascript">
function Form1_onSubmit() {
if(button clicked is btn save){
validate();
}
else return true;
}
</script>
Thank you.
|
|
|
|
|
No, you can't. Use the onclick event of each button to catch which one is clicked.
---
single minded; short sighted; long gone;
|
|
|
|
|
Mark the edit button as CausesValidation = false, then use validator controls. Should work fine.
Ben
|
|
|
|
|
You can actually pass this . And within the function you can inspect the sender's Value attribute.
|
|
|
|
|
|
Hi all
Just wondering if anyone can help me. What I am looking to do is create a control that functions similar to the latest outlook email panel. You know the middle pane on the default view that allows you select the email to look at.
So I am looking for a method of splitting/grouping rows that are being fetched from a view into a repeater dependant on a date value. I assume for this that I will have to use a nested repeater, no probs with that, but what I would also like is to be able to do is collapse each section of the view for a particular day to hide it, like outlook does. I am assuming that I could use that Ajax toolkit collapsible panel for this? But not sure if that will work around sections of a repeater? I Guess I am looking for advice as to whether this is possible and the best method for a solution. I don’t need the code…I can figure that bit out, more concerned with the actual technicalities of it actually being possible and how to do it. If indeed it is at all possible and I ain’t just wasting my time!
All help most appreciated.
Cheers
Ian
|
|
|
|
|
Hi i am trying to display my grid cell value in grid textbox...,
So i used this following code...,
For Each fillgrdregtextbox As DataGridItem In dgrdmain1.Items
Dim AppRgHrs As TextBox = CType(fillgrdregtextbox.FindControl("txtAppRgHrs"), TextBox)
Dim AppOtHrs As TextBox = CType(fillgrdregtextbox.FindControl("txtAppOtHrs"), TextBox)
If fillgrdregtextbox.Cells(25).Text <> "" Then
AppRgHrs.Text = Val(fillgrdregtextbox.Cells(25).Text)
AppOtHrs.Text = Val(fillgrdregtextbox.Cells(26).Text)
ElseIf fillgrdregtextbox.Cells(27).Text <> "" Then
AppRgHrs.Text = Val(fillgrdregtextbox.Cells(27).Text)
AppOtHrs.Text = Val(fillgrdregtextbox.Cells(28).Text)
Else
AppRgHrs.Text = 0
AppOtHrs.Text = 0
End If
Next
In this that first if condition is working...,
But that elseif is not working...,(Mentioned in bold)
Instead of that i am getting 0 on there...,
how to solve it...,
Plz tell me...,
Advance thanks...,
Regards,
Magi
|
|
|
|
|
I would suggest using findcontrol instead of using Cells(27) directly. As far as your code you should not have an elseif It should just be an if.
Ben
|
|
|
|
|
kubben wrote: you should not have an elseif It should just be an if.
There's nothing wrong with ElseIf
|
|
|
|
|
Why do you say that? He isn't looping through the cells. The first if will always hit and the elseif won't. I don't know for sure that is his problem, but it seems likely from looking at the code.
Ben
|
|
|
|
|
Sorry, I thought you were querying his syntax...
But why should the first If always hit? It may be the cell's value is blank...
|
|
|
|
|
Ok so the elseif will hit every once in a while if the first one is blank. You still don't want an elseif there.
Ben
|
|
|
|
|
He obviously does! IF there is a value in cell 25 use that and cell 26, elseif there is a value in 27 use that and cell 28, else leave blank.
|
|
|
|
|
Magh_M wrote: Instead of that i am getting 0 on there
Do you mean 0, or nothing?
Why the Val() functions, and why
Magh_M wrote: AppRgHrs.Text = 0
AppOtHrs.Text = 0
When you need to put a string into a textbox, not a number...
Where is this code - what function of your code-behind? Are you trying to insert these values in Edit rows? Post the whole function...
|
|
|
|
|
Hi all
I want to know How can we define no of rows in a window.
but this script writes all rows of that gridView.
So How can we control no of rows so we can print as many no of record as we want. Is there any other function Please let me know.
Your help is highly appreciated, Thanks
function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var strOldOne=prtContent.innerHTML;
var WinPrint = Window.open('','','letf=100,top=100,width=1000,height=1000,toolbar=0,scrollbars=1,status=0,resizable=1');
WinPrint.document.write(prtContent.outerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
Bajrang Singh
Using .net 2.0 (VS2005)
|
|
|
|
|
Hi
I responded to a post today regarding built in datasource vs custom data access objects.
After replying I began to think about these and quickly came to the realisation that I know jack all to be fair.
Obviously I shall be reading around on msdn etc but I would just like some opinions. My question is this.
How good is the datasource object regards efficiency, error handling, working under load etc.
The obvious advantage is speed of development but what are its major disadvantages?
I understand this is a very wide topic so just pointers and opinions would be great.
Thanks
Dan
|
|
|
|
|
Hi! The following problem is giving me headache now for a few days. I`m writing a aspx Webpage with C# code-behid.
In the Default.aspx Page I have a literal container which loads HTMLPages from a certain folder.
(I call //host/Default.aspx?/folderpath/filneame.htm, check for the path behind the ? char and call the HTML Page with StreamReader. Finally it is added to the litcontrol) This works fine, the only problem is, that everybody can access the file directly by inserting the path in the browser. I tried it with a web.config file which denied access for non authorized users, even denied the GET Method, but still no success.
Does anybody know how to do this? I mean the files of this certain folder should just be allowed to called if you are authorized by my Database. A direct access should be denied.
Help would be appreciated
|
|
|
|
|
ezazazel wrote: the only problem is, that everybody can access the file directly by inserting the path in the browser
Only if they know the filename... you could give it, or append to it's name before saving, a randomly generated string (say 6 chars min) and it'll be all but impossible that anyone will ever manage to browse to it. If the file/s change/s, you could store the filename/s in the db (or an xml file) and recall as needed...
For that matter, of course, you could just store the file contents in the db to begin with.
Yes, no doubt the Authentication classes can solve this problem more elegantly, but as you say.... you need some headache tablets handy... I must say, I've never managed to get my head around them....
|
|
|
|
|
Hi.am doing one music.in this site am keeping all the songs in the webserver.so while opening the songs page user can select all songs or some songs for play.after selecting the songs am adding the selected songs into play list.so my question is where i can keep this play list.when i tried to add this playlist into client machine getting access denied error.suppose if am storing that playlist in the server it will take time to play all the songs from the playlist,and also if am keeping in the server so many files will come in the server and size also increase.so what is the solution for playing the selected songs very fastly.somebody can get me some idea.
|
|
|
|
|
You will have to keep it on the server, obviously.
Kurian_Kurian wrote: suppose if am storing that playlist in the server it will take time to play all the songs from the playlist
How so ? The *songs* are on the webserver, but you think keeping a list of their names on the web server is going to be a speed issue ?
Kurian_Kurian wrote: so what is the solution for playing the selected songs very fastly
Can't you just serve them in order ? How do you play them ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have 2 RadioButtons in my page, and I have to change the visibility of 2 Asp Panels depending on which RadioButton is clicked. I use this JavaScript function for this:
function ToggleRbn1(p)
{ //alert(p.id);
if(document.getElementById(p.id).checked == true)
{
var id1 = document.getElementById('<%=pnlType1.ClientID%>');
var id2 = document.getElementById('<%=pnlType2.ClientID%>');
//alert(id2.innerHTML);
id2.style.display = "none";
id1.style.display = "block";
}
}
function ToggleRbn2(p)
{ //alert(p.id);
if(document.getElementById(p.id).checked == true)
{
var id1 = document.getElementById('<%=pnlType1.ClientID%>');
var id2 = document.getElementById('<%=pnlType2.ClientID%>');
id2.style.display = "block";
id1.style.display = "none";
}
}
I initially set Panel2 as invisible, but id2 would give error that time. If I keep it visible=true, then there is no problem. But that is not the requirement, Panel2 should be invisible at Page_Load, it should be visible only when user clicks RadioButton2. Error is: "Object Required".
Regards,
Blumen
|
|
|
|
|