You need hard work to get Lucky!

They are ill discoverers that think there is no land, when they can see nothing but sea.

Archive for the ‘Asp.net’ Category

Paste Text from outside Editor (clipboard) into Nano Editor

Posted by zeemalik on February 28, 2014

If you are having trouble in copy/pasting text from outside into nano editor, then you just need to use this command:

Press SHIFT + INSERT

If you want to delete the existing text before inserting/pasting new text in the file then first delete the text character by character by using this command:

Press CTRL + D

I hope this helps.

Regards,

Zeeshan 

Posted in Asp.net | Leave a Comment »

Configuring Notification Scheme with Custom Workflow in JIRA

Posted by zeemalik on October 25, 2013

If you are using a customized workflow in JIRA then you might need to send notifications to related people or group of people based on different transitions in your workflow. This can be done very easily by creating custom events, using those events in post-functions of each transition in the workflow and setting up the notification scheme to send notification on those events. JIRA basically works on events and listeners model. We need to use that effectively as below:

1. Create custom events by going to: Image > System > Advanced – Events. You should create as many events as you have the transitions in your workflow. For example if you have a transition “Resolved” in your work flow then create an event “Resolved” for this and similarly for other transitions. Once the events have been created you need to use them in postfucntions of transitions in your workflow and also in notification scheme.

2. Go to “Post Functions” of each of the transition in your customized workflow. There will be a post function called “Fire a Generic Event event that can be processed by the listeners.”. Edit it and set the event in drop down same as the name of the transition. Example: if you are editing the post function of “Assigned” transition then you need to set the event “Assigned” in drop down and respectively for all other transitions in the workflow. Once done with all the transitions, publish the workflow.

3.  Go to Image > System > Notification Schemes and select the notification scheme you will be using for those projects having your customized workflow. Now in that notification scheme you need to set notifications (Roles, Groups or individual users emails) for each of the events created in step 1. 

Once you have performed above three steps and you are using the notification scheme with your projects (using your customized workflow) then you are all set. When ever a transition will occur in your workflow the email notification will be sent to assigned users in step 3.

I hope this will help you in configuring the correct notification scheme with your customized workflow in JIRA.

 

For further help contact: zeemalik78@yahoo.com

CHEERS 🙂

Posted in Asp.net | Leave a Comment »

How to handle single quote in SQL Query or DataSet.Select ?

Posted by zeemalik on June 30, 2010

Problem : When we try to select/filter records based on a column value which contains a single quote then the SQL server will give syntax error because there is a single quote in the start and at the end of SQL query normaly.

Solution 1:  Parameterized Query

We can use parameterized query to avoid the single quote issue like this:

string VendorName = “John O’Corner”;

command.CommandText = “SELECT * FROM Products WHERE VendorName= @VendorName”;

command.Parameters.Add(
       new SqlParameter(“@VendorName”, SqlDbType.VarChar, 50)).Value = VendorName;

Solution 2:  Replace Single Quote

Another option is that you can replace single quote with two single quotes. This will give an effect of a string end then string start in SQL Query. This method is especially suitable while we are selecting records in a dataset.

SystemDataSet.ProductRow[] productRows =  dataSet.Products.Select( ” VendorName = ‘” + VendorName.Replace( “‘”, “”” ) + “‘” );

Posted in Asp.net | Tagged: , , , | 2 Comments »

How to access deleted rows in a typed dataset?

Posted by zeemalik on March 9, 2010

 

Sometimes after doing some processing on a dataset and before finally committing the changes in the database we need to know some information about added, modified, deleted or dispatched rows in the dataset. One of the well known approaches  is to loop the rows of a data set and check the ‘RowState’ value of each row which could be added, modified, deleted or dispatched. But when you are using a transaction in your code then you will notice that after updating the changes in database and before committing the transaction you will lose the deleted rows although you will still be able to get the rowstate of added and modified rows. This was irritating for me as i wanted to get the count of deleted rows in my code. The fortunately i came accross another nicer method of accessing added, modified, deleted and dispatched rows which is Table.GetChanges(‘RowsState’). In this way you can separately make tables for each kind of rows and then use them for your purpose. Here is an example of ‘Customer’ table.

 DataTable tableAddedRows, tableModifiedRows, tableDeletedRows, tableDispatchedRows;

 tableAddedRows = myDataSet.tables[“Customer”].Rows()[0].Table.GetChanges( DataRowState.Added );
 tableModifiedRows = myDataSet.tables[“Customer”].Rows()[0].Table.GetChanges( DataRowState.Modified); 
 tableDeletedRows = myDataSet.tables[“Customer”].Rows()[0].Table.GetChanges( DataRowState.Deleted );
 tableDispatchedRows = myDataSet.tables[“Customer”].Rows()[0].Table.GetChanges( DataRowState.Dispatched);


Now you can use these tables to do whatever you want. Please note that if there is no row of any one of these rowstates then its corresponding table will be null.

I hope this helps!

Posted in Asp.net | Leave a Comment »

The SMTP server requires a secure connection or the client was not authenticated

Posted by zeemalik on February 18, 2009

Problem: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. c25sm1228430ika.11

 

 

Solution:

 

 

Public Shared Sub SendEmail()

 

 

    Dim Message As New Net.Mail.MailMessage()

 

    Dim FromEmail As New Net.Mail.MailAddress(“From Email Address”)

    Message.From = FromEmail

    Message.To.Add(“To Email Address”)

 

 

    Message.Subject = “Subject of the Email”

    Message.Body = “Body of the Email”

    ‘Message.SubjectEncoding = System.Text.Encoding.UTF8

    ‘Message.BodyEncoding = System.Text.Encoding.UTF8

    ‘Message.IsBodyHtml = False

    ‘Message.Priority = Net.Mail.MailPriority.High

 

    Dim SmtpClient As New Net.Mail.SmtpClient(“smtp.YourEmailServer.com”, PortNo eg: 587 for gmail )

    SmtpClient.EnableSsl = True

    ‘smtp.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network

    ‘smtp.UseDefaultCredentials = False

 

SmtpClient.Credentials = New Net.NetworkCredential(“YourEmailAddress”, “YourEmailPassword”)

 

    SmtpClient.Send(Message)

 

 

End Sub

 

Note: An important point to note is that you have to set the EnableSSl to True before you set the NetWork Credentials of your SMTP client.

AddThis Social Bookmark Button
View zeeshan malik's LinkedIn profileView zeeshan malik’s profile

Posted in Asp.net | 18 Comments »

How to call client-side Javascript function after an UpdatePanel asychronous (Ajax) request is over

Posted by zeemalik on November 27, 2007

If you are using AJAX then the only way i have found yet to give an alert to a user on return to the Asynchronous post back is to add an “end request” handler to the PageRequestManager.

In this way you can tell the request manager to run a javascript function on returning from a Asynchronous post back event of AJAX.

Code for doing this is :

function load()

{
   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

where “EndRequestHandler” will be the name of your javascript function you want to call.
Call the above function in Onload event of <body> tag:

<body onload=”load()”>

function EndRequestHandler()

{

          alert(“You record has been saved successfully”);

}

Now If you want to give a different message based on your logic in server side code (code behind) then you can use a server side Hidden Field:

<input id=”hdnValue” type=”hidden” runat=”server”  value=”” />

Set its value in server side code on Asychronous Post Back: 

Protected Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCreateSample.Click

    If condition Then

hdnValue.value = “do this”

    Else     

hdnValue.value = “do that”

    End If 

End Sub

Now you can check the value of this Hidden Field in your Client Side EndRequestHandler function and give a different alert to user based on its value:

function EndRequestHandler()
{
     if (document.getElementById(‘<%= hdnValue.ClientID %>’).value == “do this”)

     { 
          alert(“You record has been saved successfully”);
     } 
     else
     {
          alert(“There is an error”);
     }
 }

AddThis Social Bookmark Button  
View zeeshan malik's LinkedIn profileView zeeshan malik’s profile

Posted in AJAX, Asp.net, Asychronous post back, Javascript | Tagged: , , , , , , | 56 Comments »