Tuesday

alter table with check constraint


SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[web_contracts] WITH NOCHECK ADD CONSTRAINT [CK_web_contracts] CHECK NOT FOR REPLICATION (([payment_source]=(3) AND len(isnull([eft_routing_number],''))=(9)))
GO
ALTER TABLE [dbo].[web_contracts] CHECK CONSTRAINT [CK_web_contracts]
GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Routing number is not specified' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'web_contracts', @level2type=N'CONSTRAINT',@level2name=N'CK_web_contracts'

ASP.NET/csharp:FileUpload inside AJAX Update panel

To make it working it's required :
1.Created interface:

public interface ITriggerable {
void RegisterPostbackTrigger(Control parent,Control trigger);
}


2.implement this interface on page containing ajax update panel:

public void RegisterPostbackTrigger(Control parent,Control button){
PostBackTrigger trigger = new PostBackTrigger();
trigger.ControlID =((Button) button).UniqueID;
UpdatePanel1.Triggers.Add(trigger);
}


3.Add button inside of control as trigger:

protected override void OnInit(EventArgs e){
base.OnInit(e);
((ITriggerable)this.Page).RegisterPostbackTrigger(this, btnRename);
}

WebRequest Exception 401: The remote server returned an error: (401) Unauthorized.

it's required to add default credentials:
request.Credentials = CredentialCache.DefaultCredentials;
See this post for complete source.

Charp (C#):validate http links



public bool ImageExists(string url) {
Uri urlCheck = new Uri(url);

WebRequest request = WebRequest.Create(urlCheck);
request.Credentials = CredentialCache.DefaultCredentials;

request.Timeout = 15000;

WebResponse response;
try {
//get URL web response
response = request.GetResponse();
return true;
}
catch (Exception){
return false; //url does not exist
}
}

JQuery working inside UpdatePanel

To make jquery works inside Update panel you have to add handler to updatepanel reload with restorig jquery bindings :

1. create jquery binding function , to specific links for example:

function re_init(p1,p2){
$('a[name=modal]').click(function(e) {
// Add your jquery bindings here
// ...
//
}
}


2 on document ready add handling UpdatePanel reload

$(document).ready(function() {
re_init(null,null);
// add re-initialisation after update panel reloading
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(re_init);
});

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...