ASP.Net JSON post with basic auth

25 Ağu 2020 In: .net
string url = "https://zkapigw.xbank.com.tr:8443/api/accountService";

                User user = new xbank.User()
                {
                    associationCode = "195000_XYX_TICARET",
                    startDate = "2019-09-28T00:00:00",
                    endDate = "2019-10-05T00:00:00"
                };
                var json = JsonConvert.SerializeObject(user);

                HttpWebRequest http = (HttpWebRequest)WebRequest.Create(new Uri(url));
                http.Credentials = CredentialCache.DefaultCredentials;
                http.ContentType = "application/json";
                http.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(username + ":" + password));
                http.AllowAutoRedirect = true;
                http.Method = "POST";

                ASCIIEncoding encoding = new ASCIIEncoding();
                Byte[] bytes = encoding.GetBytes(json);

                Stream newStream = http.GetRequestStream();
                newStream.Write(bytes, 0, bytes.Length);
                newStream.Close();

                var response = http.GetResponse();
                var stream = response.GetResponseStream();
                var sr = new StreamReader(stream);
                var responseText = sr.ReadToEnd();

                Hareketler distance = JsonConvert.DeserializeObject<Hareketler>(responseText);

Clean html tags in string

17 Tem 2020 In:
System.Text.RegularExpressions.Regex.Replace("<b >ali< /b>", "<.*?>", string.Empty);

RadioButton in Repeater

12 Haz 2020 In:


            $('input[type=radio]').click(function () {
                $('input[type=radio]').removeAttr("checked");
                $(this).prop('checked', true);
            });
 
 
 

colorbox iframe den parent tetikleme

12 Haz 2020 In:

iframe içerisinde :
 
<input type="button" class="btn btn-primary" value="KAPAT" onclick="modalkapat();"/>
  
 
 <script>
        function modalkapat() {
            //window.parent.$("#ContentPlaceHolder1_lbtn_yenile").click();
            //window.parent.$("#ContentPlaceHolder1_txt_Note").val('asdas');
            window.parent.__doPostBack('ctl00$ContentPlaceHolder1$lbtn_yenile', '');
            parent.jQuery.colorbox.close();
            return false;
        }
 </script> 
 
 
 
veya
 
 
 
    <link rel="stylesheet" href="css/colorbox.css" />
    <script type="text/javascript" src="js/jquery.colorbox.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".iframe").colorbox({ iframe: true, width: "80%", height: "80%", onClosed: function () { __doPostBack('ctl00$ContentPlaceHolder1$lbtn_yenile', ''); }});
        });
    </script> 

How to set max count for multi-select

6 May 2020 In:
 
 
 
 
var maxCount = 3;
$("#typeCheckboxSelect").multiselect({
includeSelectAllOption: true,
enableCaseInsensitiveFiltering: true,
numberDisplayed: 1,
maxHeight: 250,
includeSelectAllOption: false,
onChange: function(option) {
//Get selected count
var selectedCount = $("#typeCheckboxSelect").find("option:selected").length;
//If the selected count is equal to the max allowed count (3 here), then disable any unchecked boxes
if (selectedCount >= maxCount) {
$("#typeCheckboxSelect option:not(:selected)").prop('disabled', true);
$("#typeCheckboxSelect").multiselect('refresh');
alert("Only allowed to select " + maxCount + " options.");
}
//If the selected count is less than the max allowed count (3 here), then set all boxes to enabled
else {
$("#typeCheckboxSelect option:disabled").prop('disabled', false);
$("#typeCheckboxSelect").multiselect('refresh');
}
} 
}); 
 

CKEditor Kulanımı

16 Nis 2020 In:
<script src="https://cdn.ckeditor.com/4.14.0/basic/ckeditor.js"></script>
 
  <textarea cols="80" id="editor1" name="editor1" rows="10" data-sample-short runat="server"></textarea>
 
 
<script>
CKEDITOR.replace('editor1', {
height: 150
});
</script>

SameSite cookies in ASP.NET

7 Nis 2020 In:

Setting the SameSite property to Strict, Lax, or None results in those values being written on the network with the cookie.
 
<configuration> <system.web> <httpCookies sameSite="[Strict|Lax|None|Unspecified]" requireSSL="[true|false]" /> <system.web> 
<configuration> 

ASP.Net also issues four specific cookies of its own for these features: Anonymous Authentication, Forms Authentication, Session State, and Role Management. Instances of these cookies obtained in runtime can be manipulated using the SameSite and Secure properties just like any other HttpCookie instance. 

 

For best resource about this topic  https://docs.microsoft.com/en-us/aspnet/samesite/system-web-samesite 

 

   <system.web>
    <compilation debug="false" targetFramework="4.5.2"/>
    <httpRuntime targetFramework="4.5" executionTimeout="200" maxRequestLength="12096" requestValidationMode="2.0"/>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="tr-TR" uiCulture="tr-TR"/>
    <sessionState timeout="360" cookieSameSite="None"/>
    <httpCookies sameSite="None" requireSSL="false" />
    <pages maintainScrollPositionOnPostBack="true" validateRequest="false"/>
    <customErrors mode="RemoteOnly" defaultRedirect="Hata.aspx" redirectMode="ResponseRewrite"/> 
   </system.web>

 

  https://support.episerver.com/hc/en-us/articles/360039331931-IFrame-issues-after-Microsoft-changed-default-settings-to-SameSite-cookie-attribute

 

<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="tr-TR" uiCulture="tr-TR"/>

    <sessionState timeout="360" cookieSameSite="None"  cookieless="false" />

    <httpCookies sameSite="None" requireSSL="false" />

    <httpRuntime executionTimeout="240" maxRequestLength="500000"/>

    <pages maintainScrollPositionOnPostBack="true" enableEventValidation="false" viewStateEncryptionMode="Never" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>

    <webServices>

      <protocols>

        <add name="HttpGet"/>

        <add name="HttpPost"/>

      </protocols>

    </webServices>

    <compilation debug="true" targetFramework="4.5.2"/> 

jQuery ve JS ipuçları

29 Mar 2020 In:

Selector Example Selects
* $("*") All elements
#id $("#lastname") The element with id="lastname"
.class $(".intro") All elements with class="intro"
.class,.class $(".intro,.demo") All elements with the class "intro" or "demo"
element $("p") All <p> elements
el1,el2,el3 $("h1,div,p") All <h1>, <div> and <p> elements
     
:first $("p:first") The first <p> element
:last $("p:last") The last <p> element
:even $("tr:even") All even <tr> elements
:odd $("tr:odd") All odd <tr> elements
     
:first-child $("p:first-child") All <p> elements that are the first child of their parent
:first-of-type $("p:first-of-type") All <p> elements that are the first <p> element of their parent
:last-child $("p:last-child") All <p> elements that are the last child of their parent
:last-of-type $("p:last-of-type") All <p> elements that are the last <p> element of their parent
:nth-child(n) $("p:nth-child(2)") All <p> elements that are the 2nd child of their parent
:nth-last-child(n) $("p:nth-last-child(2)") All <p> elements that are the 2nd child of their parent, counting from the last child
:nth-of-type(n) $("p:nth-of-type(2)") All <p> elements that are the 2nd <p> element of their parent
:nth-last-of-type(n) $("p:nth-last-of-type(2)") All <p> elements that are the 2nd <p> element of their parent, counting from the last child
:only-child $("p:only-child") All <p> elements that are the only child of their parent
:only-of-type $("p:only-of-type") All <p> elements that are the only child, of its type, of their parent
     
parent > child $("div > p") All <p> elements that are a direct child of a <div> element
parent descendant $("div p") All <p> elements that are descendants of a <div> element
element + next $("div + p") The <p> element that are next to each <div> elements
element ~ siblings $("div ~ p") All <p> elements that are siblings of a <div> element
     
:eq(index) $("ul li:eq(3)") The fourth element in a list (index starts at 0)
:gt(no) $("ul li:gt(3)") List elements with an index greater than 3
:lt(no) $("ul li:lt(3)") List elements with an index less than 3
:not(selector) $("input:not(:empty)") All input elements that are not empty
     
:header $(":header") All header elements <h1>, <h2> ...
:animated $(":animated") All animated elements
:focus $(":focus") The element that currently has focus
:contains(text) $(":contains('Hello')") All elements which contains the text "Hello"
:has(selector) $("div:has(p)") All <div> elements that have a <p> element
:empty $(":empty") All elements that are empty
:parent $(":parent") All elements that are a parent of another element
:hidden $("p:hidden") All hidden <p> elements
:visible $("table:visible") All visible tables
:root $(":root") The document's root element
:lang(language) $("p:lang(de)") All <p> elements with a lang attribute value starting with "de"
     
[attribute] $("[href]") All elements with a href attribute
[attribute=value] $("[href='default.htm']") All elements with a href attribute value equal to "default.htm"
[attribute!=value] $("[href!='default.htm']") All elements with a href attribute value not equal to "default.htm"
[attribute$=value] $("[href$='.jpg']") All elements with a href attribute value ending with ".jpg"
[attribute|=value] $("[title|='Tomorrow']") All elements with a title attribute value equal to 'Tomorrow', or starting with 'Tomorrow' followed by a hyphen
[attribute^=value] $("[title^='Tom']") All elements with a title attribute value starting with "Tom"
[attribute~=value] $("[title~='hello']") All elements with a title attribute value containing the specific word "hello"
[attribute*=value] $("[title*='hello']") All elements with a title attribute value containing the word "hello"
     
:input $(":input") All input elements
:text $(":text") All input elements with type="text"
:password $(":password") All input elements with type="password"
:radio $(":radio") All input elements with type="radio"
:checkbox $(":checkbox") All input elements with type="checkbox"
:submit $(":submit") All input elements with type="submit"
:reset $(":reset") All input elements with type="reset"
:button $(":button") All input elements with type="button"
:image $(":image") All input elements with type="image"
:file $(":file") All input elements with type="file"
:enabled $(":enabled") All enabled input elements
:disabled $(":disabled") All disabled input elements
:selected $(":selected") All selected input elements
:checked $(":checked") All checked input elements
 
// 
        function fn_possec(pos_id)
        {
            console.log('b');
            //tutar kontrol
            tutar=0.0;
            if (isNaN(parseFloat($("[id$='txt_tutar']").val())) || isNaN(parseFloat($("[id$='txt_tutarkr']").val()))) { toastr['warning']('Tutar bilgisinde hata var.'); return; }
            tutar = parseFloat($("[id$='txt_tutar']").val()) + (parseFloat($("[id$='txt_tutarkr']").val()) / 100);
            if (tutar <= 0) { toastr['warning']('Tutar bilgisinde hata var.'); return; }
            console.log(tutar);
            $("[id$='hid_POS_ID']").val(pos_id);
            $("[id$='hid_tutar']").val(tutar);
        }
 

//value of Textbox
$("[id$='txt_tutar']").val()  


//Ends With
$("input[name$='pt']").css("color", "green");
$("[id$='pt']").css("color", "green");
 
 
        $("[id$='chk_UOB00_aktifler']").change(function () {
            if (this.checked) {
                $(".uoaktif").show();
                $(".uopasif").hide();
            }
            else {
                $(".uoaktif").show();
                $(".uopasif").show();
            }
        });
 
 
If you know the element type then: (eg: replace 'element' with 'div')
$("element[id$='txtTitle']")
If you don't know the element type:
$("[id$='txtTitle']") 
 
 
 // DOM ELEMENTS
$('div').each(function(index, value) {
  console.log('div${index}: ${this.id}');
});
 
// 
 $("a").each(function (index, value) {
  console.log("anchor" + index + ":" + $(this).attr("href"));
});
 
//
var allDiv = $("div");
for ( var i=0; i<allDiv.length; i++) {
    // use allDiv[i] for accessing each one
 
 
 
--------------------------- 
 
 
<div class="testimonial" data-index="1">
    Testimonial 1
</div>
<div class="testimonial" data-index="2">
    Testimonial 2
</div>
<div class="testimonial" data-index="3">
    Testimonial 3
</div>
<div class="testimonial" data-index="4">
    Testimonial 4
</div>
<div class="testimonial" data-index="5">
    Testimonial 5
</div>

$('div[class="testimonial"]').each(function(index,item){
    if(parseInt($(item).data('index'))>2){
        $(item).html('Testimonial '+(index+1)+' by each loop');
    }
});

Testimonial 1
Testimonial 2
Testimonial 3 by each loop
Testimonial 4 by each loop
Testimonial 5 by each loop 
 
 
---------------------------

Ben Kimim ?

Celiker BahceciMerhabalar, ben Çeliker BAHÇECİ. 2004 den beri özel sektörde bilgisayar mühendisligi ve egitmenlik yapıyorum. Yine aynı yılın Ekim ayından beri sitemde .Net ile programlama ve hayat görüşüm ile ilgili makalelerimi yayınlıyorum. Blogum dışında Yazgelistir.com, mobilnedir.com gibi ineta kapsamındaki bir çok siteye Microsoft teknolojileri ile ilgili yazılar yazmaktayım.
Bu site ile sizinde hayatınızı anlamlandırmanızda bir parça katkımın olması dilegiyle...