Reuse of javascript code with asp.net -


i've taken on development of website written in asp.net. before taking on, have spent little time web applications. have no experience in area, hesitant criticise, feel website badly written.

look @ following search results produced visual studio:

  \website\js\admin_userprofile.js(715):function sendinvite() {   \website\js\admin_userprofilepro.js(745):function sendinvite() {   \website\js\mycontactdetails.js(466):function sendinvite() {   \website\js\mycontactdetailspro.js(466):function sendinvite() {   \website\js\mycontactrequestspro.js(676):function sendinvite() {   \website\js\mycontacts.js(239):function sendinvite()   \website\js\mycontactspro.js(240):function sendinvite()   \website\js\mygroups.js(103):function sendinvite()   \website\js\myprofile.js(715):function sendinvite() {   \website\js\myprofilepro.js(745):function sendinvite() {   \website\js\search.js(55):function sendinvite() {       \website\js\searchpro.js(55):function sendinvite() {                            \website\search.js(44):function sendinvite() { 

each of functions same. has copied whole block of code whenenever feel page needs sendinvite() functionality. in related .aspx pages, there link click on calls function, , couple of hidden popups called javascript things "are sure want send invite?" in way agrees rest of site design.

cloned code terrible, , difficult maintain. however, don't know how go making nicer. can wrap functionality here - javascript , popup stuff - 1 device can reference wherever needed? i've read use of .ascx pages (sparingly used in source code have inherited), don't know if safe use these javascript included too.

shudder

there nothing worse code duplicated on place.

the simplest thing copy function in single js file, delete code of other js files , make sure new script file included in pages call 1 of functions use using script tag in html.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -