Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-10-18
8
Medium Priority
?
288 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:JRFromSoCal
  • 4
  • 4
8 Comments
 
LVL 9

Expert Comment

by:Evan Cutler
ID: 36988100
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.
0
 
LVL 1

Author Comment

by:JRFromSoCal
ID: 36988305
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

0
 
LVL 9

Expert Comment

by:Evan Cutler
ID: 36988340
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.  
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:JRFromSoCal
ID: 36988446
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.
0
 
LVL 9

Expert Comment

by:Evan Cutler
ID: 36988463
can you show me the ajax call?
is it jquery?

thanks.
0
 
LVL 1

Author Comment

by:JRFromSoCal
ID: 36988509
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

0
 
LVL 9

Accepted Solution

by:
Evan Cutler earned 2000 total points
ID: 36988568
perfect...This changes everything.

just before the second }); the last closout....

insert
$("#idc_ticket_id").val('');
or

$("#idc_ticket_id").val() = '';

I forget which, this is a jquery thing.
0
 
LVL 1

Author Closing Comment

by:JRFromSoCal
ID: 36988919
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question