Link to home
Start Free TrialLog in
Avatar of JRFromSoCal
JRFromSoCalFlag for Afghanistan

asked on

Need to know how to clear textbox create by linq xelement.

I'm using this code to create a textbox.  The user enters a ticket number, presses the save button and the data in the textboxes gets saved to the db.  That's working fine.  Now I want the data (that has just been saved) to be cleared from the textbox.  This will make it easier for the user to enter another ticket.

Regards,
J.R.  
Private Function RenderTicketItemCreateDetailHtml(ByVal OrganizationId As String) As XElement

        Dim TicketId As String = " "
        Dim SubTicketId As String = "1"

        Dim DateTicketCreated As Date = System.DateTime.Now

        Dim SpecInstructions As String = ""

        Dim _table As XElement = New XElement("table", New XAttribute("style", "width: inherit; height:inherit;"),
                                               New XElement("tr",
                                                             New XElement("td",
                                                                          New XElement("table", New XAttribute("style", "width: inherit; height:inherit;"),
                                                                                New XElement("tr",
                                                                                             New XElement("td", New XAttribute("style", "width: 195px"), "Ticket ID"),
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), Me.RenderTextBoxHtml("idc_ticket_id", String.Format(TicketId)))),
                                                                                New XElement("tr",
                                                                                             New XElement("td", New XAttribute("style", "width: 195px"), "SubTicket ID"),
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), Me.RenderTextBoxHtml("idc_ticketitem_subticketid", String.Format(SubTicketId)))),
                                                                                New XElement("tr",
                                                                                             New XElement("td", New XAttribute("style", "width: 195px"), "Date Created"),
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), Me.RenderTextBoxHtml("{0}", String.Format(DateTicketCreated)))),
                                                                                New XElement("tr",
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), "Product"),
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), Me.RenderProductListDropDownListBox("idc_ticketitem_productid", OrganizationId, "width: 170px"))),
                                                                                New XElement("tr",
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), New XAttribute("valign", "top"), "Special Instructions"),
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), New XAttribute("valign", "top"), RenderTextAreaHtml("idc_ticketitem_operatorcomment", SpecInstructions, 4, 18)))))))

        Return _table

    End Function

Open in new window

Avatar of Evan Cutler
Evan Cutler
Flag of United States of America image

Where is this function being called from.
You can do a form cleanup after the function is called from.

Maybe a public cleanup() function that can be called from anywhere?

Cheers.
Avatar of JRFromSoCal

ASKER

How would that cleanup function look?  How would I access this textbox (and clear it of data) from another function?  There is actually only one of the textboxes I need cleared.  The ticket number will always be different, but the data in the other boxes would stay the same.
New XElement("table", New XAttribute("style", "width: inherit; height:inherit;"),
                                                                                New XElement("tr",
                                                                                             New XElement("td", New XAttribute("style", "width: 195px"), "Ticket ID"),
                                                                                             New XElement("td", New XAttribute("style", "width: 175px"), Me.RenderTextBoxHtml("idc_ticket_id", String.Format(TicketId)))),

Open in new window

Ok...where is this code in  your application, and what kind of application is it (ie. webform? MVC? PHP?, etc...)

Also, where is the codebehind for the page that is calling your RenderTicketItemCreateDetailHtml function.

I would put it there...
After that function is called, and completed, the memory pointer goes back to the main script...
you can clear from there.

At least that's the thought as I read this.  
This is an MVC3 webform.  The update button is clicked triggering an ajax call (this ajax call is what grabs the data from the boxes) to a function that saves to db.  The method above only creates the textboxes.  I could easily call that method again, however I would loose the data in the other boxes.  I want to keep the data in all the boxes except for the ticketid box.
can you show me the ajax call?
is it jquery?

thanks.
Here's the function.  It is jquery.
function RegisterTicketItemCreateButton(TabIndex) {


    $("#idc_ticketitem_createid").click(function (x) {

        var XmlStream = RenderXmlStreamParamters();

        TicketId = $("#idc_ticket_id").val();
        SubTicketId = $("#idc_ticketitem_subticketid").val();
        ImpressionControlId = $("#idc_ticketitem_impressioncontrolid").val();
        JobId = $("#idc_ticketitem_jobid").val();
        ProductId = $("#idc_ticketitem_productid").val();

        //
        // Begin the Xml Stream with Static Data
        //
        var XmlStream = "<Ticket>";
        XmlStream = XmlStream + "<TicketId>" + TicketId + "</TicketId>";
        XmlStream = XmlStream + "<SubTicketId>" + SubTicketId + "</SubTicketId>";
        XmlStream = XmlStream + "<ImpressionControlId>" + ImpressionControlId + "</ImpressionControlId>";
        XmlStream = XmlStream + "<JobId>" + JobId + "</JobId>";
        XmlStream = XmlStream + "<ProductId>" + ProductId + "</ProductId>";
        XmlStream = XmlStream + "<OrgId>" + OrgId + "</OrgId>";

        XmlStream = XmlStream + "</Ticket>";
        XmlStream = $("<Tickets />").text(XmlStream).html();


        $.ajax({
            type: "GET",
            url: ActionLink("Create", "TicketDBInsert"),
            data: { "TicketId": TicketId, "SubTicketId": SubTicketId, "TabIndex": TabIndex, "XmlStream": XmlStream },
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {

                if (data > 0) {
                    alert("Ticket " + data + " has successfully been created.");
                }
                else {
                    alert(data);
                }

            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert(xhr.status);
                alert(thrownError.val());
            }
        });
    });
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Evan Cutler
Evan Cutler
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This one works like a charm.  $("#idc_ticket_id").val('');
I spent several hours doing trial and error.  You saved me many more.

Thanks so much.
J.R.