« first day (1375 days earlier)      last day (3574 days later) » 

11:01 PM
@NWard Well, it appears that the issue occurs when I try to concatenate the query string.
 
Console error, or...?
 
@NWard Nope, just says that `posting` is `Object object`.

        var form = $('#<%= txtSearchPlattU.ClientID %>').val();
        var url = $(location).attr('pathname');
        var posting = $.post(url);
        alert(posting);
 
ew webforms
such an eyesore
 
@Wardy Yeah, yeah, project I'm on no choice.
 
well at least you have ugly js to keep insulting you
keeps your mind off that webform shite
 
11:10 PM
Any thoughts?
 
whats the problem ?
gimme a sec il read back
is that all you are posting ?
 
@Wardy It isn't posting it says the var posting is Object object so it doesn't actually post.
 
a search term
 
@Wardy Really, yeah.
 
i would use get for that
 
11:12 PM
The query string doesn't exist though, so my SQL Data Source has no clue wtf needs to be queried in the db until it post
 
var searchTerm = $('#<%= txtSearch.ClientID %>').val();
        var url = 'baseUrl/?q=';
        var posting = $.get(url + searchTerm, function(result) {
               // handle result
        });
you just need to hook that code up to some sort of button click handler on the client side
no sure what's going on with the rest of the markup on your page
but essentially you want something like ...
 
But how will that GET actually trigger the data source?
 
<button id="search">Search</button>
then you need something like ...
 
Are you accessing your data source from the client-side or server-side?
 
$("#search").on("click", function() {
   var searchTerm = $('#<%= txtSearch.ClientID %>').val();
        var url = 'baseUrl/?q=';
        var posting = $.get(url + searchTerm, function(result) {
               // handle result
        });
});
the client should request a url with the term in it
from there the server should build the datasource
 
11:17 PM
I would expect your url to be an endpoint which returns serialized data
 
your server code will need to look for and handle the querystring value q in this case
 
Even you code still doesn't provide a value.
 
you could go that way
 
But given that this is webforms, I'm almost expecting a control with a DataRepeater or something :P
 
@NWard Ding.
 
11:18 PM
ouch
 
Standard asp:Repeater
 
Ok hmm
 
then you shouldn't be doing this on the client from what I understand if you choose to use a repeater
 
Yeah you'll need to write an asp:Button which has a linked function in your .ascx.cs
Which then gets the repeater from the control and does your data stuff
 
Those standard buttons aren't as clean looking.
 
11:20 PM
from what I can remember you can put the repeater and the search controls in to an ajax panal and the framework should do most the hard work for you
 
Code-wise or visually? You can add any CSS you want
 
Visually the asp:button isn't as clean.
 
You can use the CssClass property of the asp:button to set its appearance to anything you like
 
thats why i tend to use a framework like kendo
you get nice looking for free effectively
with virtually no work
 
I just want to have a magnifying glass next to the button.
 
11:22 PM
you could also use something like bootstrap
 
Use the :before or :after pseudo-selectors with a font character or sprite
 
so plop an image tag in there next to the button greg
 
@Wardy Making it horrible looking, I've gotta go. I'll catch you all later.
 
again thats just css
and a nice image
 
@Wardy Yeah, I could do that. I'm trying to learn this approach though.
 
11:25 PM
you could do it the best way
write a simple control that renders an mvc view on the page
then you will get total char by char control over exactly whats on that page
we did that for an older app we had internally
its a hybrid mvc and webforms app
 
@Wardy Boss won't let me.
 
even got mvc and webforms components talking to each otehr on some pages
 
@Wardy I'm also the new guy.
 
Mixing MVC and webforms is a horror.
 
webforms is so 10 years ago now ... what have you got yourself in to @Greg !!!
 
11:27 PM
You can easily make it look nice with CSS, that shouldn't be an issue.
And using an asp:button or a standard HTML input tag shouldn't make a difference, they render out to the same thing in the end.
 
ish
 
Well, with crufty ASP IDs and so forth
 
thats a matter of opinion in some cases
lol
 
But as far as styling goes they'll be identical
 
Nothing like an HTML HREF attribute being used to call a javascript function to display a dialog of some javascript code containing SQL
 
11:28 PM
webforms does add a lot of garbage to your markup
thats quality @SpencerRuport
do you do that often ?
id love to code review that mess lol
 
prompt("Please enter your SQL Query")
 
do you even know what it does when you finish writing it ?
lol
i used to work for a company where the cto refused to use sql server because it was too complicated for him
he prefered to work entirely in access
this is the guy running all tech for a company that specialises in cleaning other companies crm data
that worked fine til he came to me one day and said ... i need help fixing this access db ... this query is taking too long to run
its been running for 3 days and still going
not suprising because he took the clients sql backup file and imported in to acces so he could work with it
30 million records in a single access table
soooo perty
now i question the boss all the time weather they are right or not ... just to make them totally clear on what they are saying
 
<MARQUEE><A HREF="JAVASCRIPT:var r = new XMLHttpRequest();r.open(\"POST\", \"hiddenAccess\", true);r.onreadystatechange = function () {if (r.readyState != 4 || r.status != 200) return;alert(\"Success: \" + r.responseText);};r.send(\"INSERT INTO Users (UserName,Password) VALUES ('admin','password')\");">New User</A></MARQUEE>
 
needless to say ... i wasn't at that previous company very long
<a href="javascript:select * from contacts">click here to rape db</a>
 
That is how the pros do it
 
11:35 PM
lol
 
Well, now I got the URL correct but it just isn't actually doing the postback.
 
Make sure to post all sql strings in the http body
It is just safer that way.
 
lol yeh that'll help
 
@TravisJ I'm not posting SQL.
 
better still ... bind the js to your open odata endpoint
 
11:37 PM
I know I was just being facetious with the whole "prompt("Please enter your SQL Query")" suggestion earlier
 
that way its nice and quick
 
Anyways, why won't this actually post?
 
you can get any data you need from right there in your js
@Greg are you not seeing any activity in say firebug or chrome tools network tab ?
 
Won't post because the method isn't marked as post? The parameters don't match up? The method isn't exposed? You didn't rebuild? There is a lack in permissions?
 
did you hook up a button like i said
 
11:38 PM
When you try to post, what does the server respond with?
 
that was actually a get not a post
 
Facetious... That's an odd word :P
 
all its doing is requesting a url
 
If you push f12 in chrome, it will open the dev tools, go to network, post your data, and then look at the response from the server.
@RodrigoSilva - :D
 
It hits the alert, but then doesn't reload the page with the query string in the page.
 
11:40 PM
what alert greg ?
 
    function Submit() {

        var term = $('#<%= txtSearch.ClientID %>').val();
        var url = '~/TrainingSearch.aspx?search=' + term;
        var posting = $.post(url + term);
        alert(url);
        posting.done(function (data) {

            var control = $('#<%= txtSearch.ClientID %>').val();
            $("#Search-Message").text("Search results for: " + control + "\t").show({ width: '50%', display: 'inline-block' });
            $(".Delete-Icon").show();

        });

    }
So in that code, I hit my alert. But it doesn't reload the page.
 
@Greg - "Object object" is just what happens when you alert an object. It calls tostring on it and that is what you see.
 
@TravisJ Still doesn't load the page, after I click it I should be on:

localhost/TrainingSearch.aspx?search=HVAC

Basically what is in my textbox.
 
@Greg - .done is part of the promise. If it is never finished, then the function will not execute
 
var url = '~/TrainingSearch.aspx?search=' + term;
var url = '/TrainingSearch.aspx?search=' + term;
relative urls dont have ~ on the client
also you can tidy that a bit
 
11:43 PM
squiggly is part of the html razor helper syntax, not sure if old school webforms used it too
 
        $.post(url + term, function (data) {

            var control = $('#<%= txtSearch.ClientID %>').val();
            $("#Search-Message").text("Search results for: " + control + "\t").show({ width: '50%', display: 'inline-block' });
            $(".Delete-Icon").show();

        });
greg what do you get if you make the code ...
    function Submit() {

        var term = $('#<%= txtSearch.ClientID %>').val();
        var url = '~/TrainingSearch.aspx?search=' + term;
        var posting = $.post(url + term);

        posting.done(function (data) {
            alert('success');
            var control = $('#<%= txtSearch.ClientID %>').val();
            $("#Search-Message").text("Search results for: " + control + "\t").show({ width: '50%', display: 'inline-block' });
            $(".Delete-Icon").show();

        });

    }
does it alert ?
 
Yes, it does.
But the URL and page reload don't occur.
 
then its posting
this is an ajax call
the page shouldnt reload
 
I want it to reload though.
 
then dont use an ajax call
 
11:47 PM
window.location.reload();
 
do a redirect
 
?
 
window.location = url + term
 
You want to maintain the query string inside of the url?
 
@TravisJ Yeah.
 
11:48 PM
 function Submit() {

        var term = $('#<%= txtSearch.ClientID %>').val();
        window.location = '~/TrainingSearch.aspx?search=' + term;
}
 
Then do what wardy suggested, and have your method expose as a httpget
 
@Wardy A redirect?
 
I don't think the tilde is proper though, I read that is supposed to be only used on`runat=server` elements.
 
yeh i mentioned that should be removed before
my bad
 
I feel like you're confusing concepts here a bit
 
11:49 PM
 function Submit() {

        var term = $('#<%= txtSearch.ClientID %>').val();
        window.location = '/TrainingSearch.aspx?search=' + term;
}
 
If you're working in webforms, and with a server-side repeater control, don't use any javascript.
Use an asp:button with an OnClick registered to a server-side function
Let ASP generate the necessary javascript for you.
 
That works, I've gotta go though. I'll ttyl thanks guys
 
this will do a get request for the page again causing a full reload from the server using the search term as a querystring param
 
You can do some asynchronous stuff with an asp:UpdatePanel, but it sounds like you don't want any async anyway.
 
its not the most efficient way to go but then nothing about webforms is
 
11:50 PM
When in rome, use as many asp: tags as possible
Don't fight the framework, even if it is horrible
 
lol
when i used to use webforms I wrote code behind a bit like controllers
i'd do a bunch of jquery related "packaging things up to build custom posts" then call server side button clicks and stuff
it was ugly as hell but my markup was the sexiest webforms markup out there
virtually all manually generated ... lotta work but clean
all coz i hated micrsoft
starting to love microsoft with mvc though
its soooo nice
right im off
later all
 

« first day (1375 days earlier)      last day (3574 days later) »