Click here to Skip to main content
15,881,898 members
Home / Discussions / ASP.NET
   

ASP.NET

 
SuggestionRe: need help to add paging in datalist access db with vb code Pin
Richard Deeming27-Feb-15 10:31
mveRichard Deeming27-Feb-15 10:31 
Questionvb function / sub call using javascript . Pin
Member 815140727-Feb-15 8:13
Member 815140727-Feb-15 8:13 
AnswerRe: vb function / sub call using javascript . Pin
ZurdoDev27-Feb-15 9:35
professionalZurdoDev27-Feb-15 9:35 
Question"End of statement Expected" error Pin
samflex27-Feb-15 5:11
samflex27-Feb-15 5:11 
AnswerRe: "End of statement Expected" error Pin
PIEBALDconsult27-Feb-15 5:25
mvePIEBALDconsult27-Feb-15 5:25 
AnswerRe: "End of statement Expected" error Pin
Richard Deeming27-Feb-15 6:28
mveRichard Deeming27-Feb-15 6:28 
GeneralRe: "End of statement Expected" error Pin
samflex27-Feb-15 6:40
samflex27-Feb-15 6:40 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming27-Feb-15 8:04
mveRichard Deeming27-Feb-15 8:04 
OK, so it's this thread[^] from back in July?

If you make the hourDiff a public or protected field, it should be available to the data-binding code. However, it won't be populated until the custom validator has run, which isn't going to happen until the user has selected the start and end hours and posted them back to the server.

In this case, building the NavigateUrl on the server isn't going to work. You're going to need some javascript to update the URL on the client.

Start with the fixed elements which you know on the server:
ASP.NET
<asp:HyperLink ID="hdReserve" class="js_siteid"  runat="server" Text="Select"
    NavigateUrl='<%# String.Format("ReserveFacility.aspx?id={0}&facilityFees={1}&depoitAmt={2}&cancelAmt={3}&keydeptAmt={4}&extrahour={5}", Eval("siteId"), Eval("RentalFeeAmount"), Eval("DepositAmount"), Eval("CancellationAmount"), Eval("DepositAmount"), Eval("ExtraHourAmount")) %>'
/>


Then add some javascript to modify the URL when the controls change. Something like this should work:
JavaScript
$(function(){

    var parseTime = function(container, prefix){
        var hour = parseInt(container.find("select[name$=" + prefix + "Hour]").val(), 10);
        var minutes = parseInt(container.find("select[name$=" + prefix + "Minutes]").val(), 10);
        var amPm = container.find("select[name$=" + prefix + "AmPm]").val();

        switch (amPm) {
            case "AM": {
                if (hour === 12) { hour = 0; }
                break;
            }
            case "PM": {
                if (hour !== 12) { hour += 12; }
                break;
            }
            default: {
                return null;
            }
        }

        return { hour: hour, minutes: minutes };
    };

    // TODO: Check that this selector returns the correct elements:
    $("a.js_siteid").each(function(){

        var me = $(this);
        var row = me.closest("tr");
        var baseUrl = me.attr("href");

        row.on("change", "select[name$=ddlPartySize], select[name$=Hour], select[name$=Minutes], select[name$=AmPm]", function(){

            var url = baseUrl;
            var groupSize = row.find("select[name$=ddlPartySize]").val();
            if (groupSize) { url += "&groupsize=" + encodeURIComponent(groupSize); }

            var startTime = parseTime(row, "start");
            var endTime = parseTime(row, "end");
            if (startTime && endTime){
                var hourDiff = endTime.hour - startTime.hour;
                if (endTime.minutes < startTime.minutes) { hourDiff--; }
                url += "&hoursdiff=" + hourDiff.toString();
            }

            me.attr("href", url);
        });
    });
});




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: "End of statement Expected" error Pin
samflex27-Feb-15 9:03
samflex27-Feb-15 9:03 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming27-Feb-15 10:29
mveRichard Deeming27-Feb-15 10:29 
GeneralRe: "End of statement Expected" error Pin
samflex27-Feb-15 10:44
samflex27-Feb-15 10:44 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming2-Mar-15 1:43
mveRichard Deeming2-Mar-15 1:43 
GeneralRe: "End of statement Expected" error Pin
samflex2-Mar-15 4:04
samflex2-Mar-15 4:04 
GeneralRe: "End of statement Expected" error Pin
Richard Deeming2-Mar-15 7:10
mveRichard Deeming2-Mar-15 7:10 
GeneralRe: "End of statement Expected" error Pin
samflex2-Mar-15 14:55
samflex2-Mar-15 14:55 
QuestionJSON Hijacking and ASP.Net MVC Pin
Tridip Bhattacharjee27-Feb-15 1:55
professionalTridip Bhattacharjee27-Feb-15 1:55 
AnswerRe: JSON Hijacking and ASP.Net MVC Pin
Richard MacCutchan27-Feb-15 3:00
mveRichard MacCutchan27-Feb-15 3:00 
QuestionWeb site various attack and security Pin
Tridip Bhattacharjee26-Feb-15 23:55
professionalTridip Bhattacharjee26-Feb-15 23:55 
AnswerRe: Web site various attack and security Pin
Richard Deeming27-Feb-15 1:26
mveRichard Deeming27-Feb-15 1:26 
QuestionRe: Access from data from Ms access Pin
Praveen Kandari26-Feb-15 1:16
Praveen Kandari26-Feb-15 1:16 
AnswerRe: Access from data from Ms access Pin
Richard MacCutchan26-Feb-15 2:00
mveRichard MacCutchan26-Feb-15 2:00 
GeneralRe: Access from data from Ms access Pin
Praveen Kandari26-Feb-15 17:04
Praveen Kandari26-Feb-15 17:04 
Questionaccess data from ms access with date Pin
Praveen Kandari26-Feb-15 1:13
Praveen Kandari26-Feb-15 1:13 
SuggestionRe: access data from ms access with date Pin
ZurdoDev26-Feb-15 4:16
professionalZurdoDev26-Feb-15 4:16 
GeneralRe: access data from ms access with date Pin
Praveen Kandari26-Feb-15 17:06
Praveen Kandari26-Feb-15 17:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.