0

I am having a user control file without its codebehind file in dotnentnuke.

In which i have put a form in which i have one textbox and one Linkbutton.

I want to pass that textbox's value when i press the button as querystring to access it in another page.

For that i have written following code but it does not work.

 <asp:TextBox ID="txtemail" runat="server" class="txtbox" placeholder="Enter Email Here"></asp:TextBox>

<asp:LinkButton ID="LinkButton1" class="lbsubscrb" runat="server" 
                                PostBackUrl="~/Portals/_default/Skins/Gravity/Dummy.aspx?add=<% txtemail.Text %>" 
                                ForeColor="White">SUBSCRIBE</asp:LinkButton>

All answers are appreciated...

Abhay Andhariya
  • 1,989
  • 3
  • 16
  • 24

1 Answers1

0

It sounds like you really just need your own custom module, instead of trying to take an existing module, without the source code, and make it do something completely different?

That being said, if you really want to take that existing module and make it do that, jQuery is likely going to be your method of choice.

Basically you wan to hijack the click event for the button and send it elsewhere, something along the lines of the following code. I actually wrote most of this last night for another module I was working on (newsletter subscriptions, by the way) but have removed some of my logic to make it simpler for what you are trying to do

EDIT: replaced the txtbox class below to match your textbox's class

<script language="javascript" type="text/javascript">
    /*globals jQuery, window, Sys */
    (function ($, Sys) {
        $(document).ready(function () {

            var originalHref = $('.lbsubscrb a').attr('href');


            $('.lbsubscrb a').removeAttr("href");
            $('.txtbox').focus(function () {
                if($('.txtbox').val().indexOf('@')<1)
                    $('.txtbox').val('');
            });
            $('.txtbox').bind("keypress", function (e) {

                if (e.keyCode == 13) {
                    $('.lbsubscrb a').click();
                }
            });

            $('.lbsubscrb a').click(function () {
                //check if they hit enter in the textbox and submit the form
                if (validateEmail($('.txtbox').val())) {

                    //
                    //TODO: Add your jquery for the redirect call here.
                    //



                    //uncomment this line to actually use the original submit functionality
                    //eval(originalHref.replace('javascript:', ''));
                    //if postback is wanted uncomment next line
                    //$('.lbsubscrb a').removeAttr("href");
                } else {
                    alert('something wrong with your email');
                }
            });
        });
    }(jQuery, window.Sys));

    function validateEmail(email) { 
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);
    } 
</script>
Chris Hammond
  • 8,873
  • 1
  • 26
  • 34