Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi guys,

i am stuck here. i don't know jquery. please help me.

actually what happens when i click on button it displays jquery popup. but it doesn't display. when i do ctrl+shift+J i found "TypeError:document.getElementById("ctl00_ContentPlaceHolder1_txtJobDetails") is null" and "ReferenceError:DoubleBookingPopUp is not defined". here is my code:

C#
public void cmdSubmit_Click(object sender, EventArgs e)
{
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   sb.Append("<script type = 'text/javascript' language = 'javascript'>");
   lblMessage.Text = "";
   sb.Append("DoubleBookingPopUp()");
   sb.Append("</script>");
}


C#
function DoubleBookingPopUp()
{
    //window.open('SubmitNewBooking.aspx','CustomPopUp','width=350, height=200, menubar=no, resizable=no ');

    $(function() {
        // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
        $( "#dialog:ui-dialog" ).dialog( "destroy" );


        $( "#dialog-confirm1" ).dialog({
            resizable: false,
            height:500,
            width:800,
            modal: true,
            closeOnEscape: false,
            open: function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },

            buttons: {
                "Continue": function() {
                    __doPostBack('', 'DBLBooking');
                    //$( this ).dialog( "close" );
                },
                Cancel: function() {

                    $( this ).dialog( "close" );
                }
            }


        });


    })
    document.getElementById('ctl00_ContentPlaceHolder1_lblMessage').innerHTML = "";
    document.getElementById('ctl00_ContentPlaceHolder1_lblMessage2').innerHTML = "";
    return false;
}


thanks,
krunal
Posted

1 solution

I think that you should place the code that is now in cmdSubmit_Click in the Page_Load like this:

http://msdn.microsoft.com/en-us/library/ms178207.aspx[^]

and then

public void cmdSubmit_Click(object sender, EventArgs e)
{
   lblMessage.Text = "";
}

void Page_Load(object sender, EventArgs e)
{
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   sb.Append("<script type = 'text/javascript' language = "'javascript'">");
   sb.Append("DoubleBookingPopUp()");
   sb.Append("</script>");

if (!ClientScript.IsClientScriptBlockRegistered("exampleScript"))
    ClientScript.RegisterStartupScript(this.GetType(), "exampleScript",
sb.ToString());

cmdSubmit.Attributes.Add("onclick", "DoubleBookingPopUp();");
}


Or a simpler version of this would be:

C#
void Page_Load(object sender, EventArgs e)
{
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   sb.Append("<script type = 'text/javascript' language = "'javascript'">");
   sb.Append("DoubleBookingPopUp()");
   sb.Append("</script>");

cmdSubmit.Attributes.Add("onclick", sb.ToString());
}


But your function would have to return true (if you want to submit) or false (if you don't want to submit).
But I see that you already do __doPostBack, so that would not be necessary I think.
 
Share this answer
 
v10

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900